STM8 bootloader纪要

STM8 bootloader-UM0560

mcu:STM8L051F3P6,属于 STM8L Series low density

bootloder 支持

已经内置bootloader的mcu
bootloader group

没有内置bootloader的mcu

bootloder 执行流程图

bootloader执行流程图:

bootloder 传输设置

ota 同步消息SYNCHR=0x7F

支持传输的外设

从图上看,051F支持UART或者SPI
UART设置:1 start bit, 8 data bit, 1 bit 奇校验 ,1 stop bit
波特率:通过0x7F的传输,自动适配波特率,最大115200,最小4800.

传输回复
串口:1 start bit, 8 data bit, no parity bit, 1 stop bit,波特率自适应

SPI设置
• 8 data bit, MSB first
• Bit rate: Set by the host which acts as a master
• Peripheral set in slave mode with software management of NSS
• Data polarity: CPOL = 0 (SCK to 0 when idle), CPHA = 0 (the first clock transition is the
first data capture edge).

收到命令后,bl回复ACK 0x79

bootloder 外设选择

从资源的角度,我们倾向于使用spi做外设,因为uart可以预留来做用户调试用,但是目前官方提供了uart的串口下载PC客户端,方便测试。所以目前看使用uart作为bl外设可能更方便。这里也就要求选用单片机时,最好是多串口的设备。

bootloder 跳转地址表

关键点检测后,要跳转的地址表:

目前我们可以先考虑实现串口的版本,但是最后还是SPI的更实用。

完整文档:UM0560

通过acme的DNS方式实现letsencrypt通配证书泛证书的自动更新

详细完整参见:
https://github.com/Neilpang/acme.sh/wiki/说明

文章已经讲的很详细了,现就就DNS和通配相关的使用做简要摘录和关键步骤说明

想要实现通配证书,目前dns方式是唯一的方式。

  1. 安装

    curl  https://get.acme.sh | sh
  2. 重定向
    打开 .bashrc,添加 alias acme.sh=~/.acme.sh/acme.sh ,方便命令输入

  3. 生成证书。
    默认dns是需要手动添加域名记录验证归属合法性的,通过dnspod这样的第三方平台 API,我们就可以实现自动验证的功能。

    export DP_Id="1234"
    export DP_Key="sADDsdasdgdsf"
    acme.sh   --issue   --dns dns_dp   -d  *.aa.com

    dnspod的token申请路径:https://www.dnspod.cn/console/user/security

这期间可能提示你需要:

acme.sh --register-account -m aaa@bbb.com

注意,DNS的账号信息,只需要操作一次,系统会自动记录到配置文件,后面直接使用"--dns dns_dp" 就可以。

  1. 证书的安装
    证书默认是在~/.acme.sh/通配域名/目录下的,通过安装可以安装到我们指定的生产环境路径。

注意,下面的命令不会自动创建目录,如果目录不存在,需要手动提前创建。

rsa 密钥:

acme.sh --install-cert -d *.aa.com --key-file /path/domain/privkey.pem --fullchain-file /path/domian/fullchain.pem --reloadcmd "systemctl force-reload nginx.service"

说明:以上两个路径是安装的目的地址,也就是将第3步的证书内容,按照这个命令中的地址,进行安装。

ecc 密钥:

acme.sh --install-cert --ecc -d *.aa.com --key-file /path/domain/privkey.pem --fullchain-file /path/domian/fullchain.pem --reloadcmd "systemctl force-reload nginx.service"

以上相关的操作都会被acme脚本自动记录,并且在证书自动更新的时候会自动执行。

  1. 证书的更新
    完成以上后,acme就会自动帮你更新证书了。

  2. acme.sh本身的自动更新
    开启:acme.sh --upgrade --auto-upgrade
    关闭:acme.sh --upgrade --auto-upgrade 0

  3. acme的卸载
    acme.sh --uninstall

alios vsc 插件错误

点击项目和平台时,VSC提示错误:
ENOENT: no such file or directory, scandir 'C:\Users\xxx.aos\AliOS-Things\board'

很显然是alios-studio插件的系统路径和实际安装的不符。
在VSC中,点击设置,在右侧有"用户设置"和"工作区设置",点击工作区设置,指定对应的路径如下:

{
  "aliosStudio.sdkPath": "xxxxx\\AliOS-Things"
}

phpadmin错误

  1. 配置文件现在需要一个短语密码
    解决:设定 libraries/config.default.php 文件的 $cfg['blowfish_secret'] 参数,参数字符串长度必须在32位以上。
  2. .$cfg[‘TempDir’] (./tmp/) 读取失败且不能建立缓存, phpMyAdmin运行速度将受影响
    解决:在phpadmin的web目录根目录下,创建缓存目录:
    sudo mkdir -m 777 ./tmp

Best espresso machines

Vivamus fringilla euismod pharetra. Proin cursus gravida nunc a placerat. Nunc nec sollicitudin nibh. Sed vel elementum lectus. Nunc nec congue quam, vitae varius massa. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce eu consectetur mi.

 

 

Vestibulum et euismod nulla. Fusce quam nulla, tincidunt ac dignissim porta, facilisis id turpis. Ut viverra pharetra massa, et auctor orci convallis sit amet. Nullam eu vulputate elit. Fusce nunc purus, hendrerit vitae est vitae, feugiat consectetur urna. Praesent eget nisl at nibh tincidunt gravida vitae sit amet nibh.

 

Listening sounds like a ridiculous characteristic for mentoring, but genuinely being invested and interested in people, meeting them for cups of coffee and spending time with people, and using the network I've been very lucky to build up to help others are all things I do to help others.
Sinead Burke

Malesuada vel finibus necDonec eu dolor erat.

Morbi purus augue, varius at enim. Morbi molestie cursus dolor, nec lacinia velit dictum eget. Cras tortor nisi, porttitor eget malesuada ac, vestibulum non justo. Integer vel molestie libero. Quisque eget sagittis enim, ut volutpat velit. Donec purus nisi, pharetra at consequat at, venenatis vel lectus.

Proin viverra consectetur felis, a accumsan felis tincidunt ut. Ut cursus lacus sed pulvinar viverra. Duis eu magna vestibulum risus dignissim condimentum quis sed nulla. Duis iaculis purus vel vestibulum facilisis. Sed gravida viverra dui pulvinar condimentum. Suspendisse eget eros at ipsum pulvinar pellentesque. Etiam ac nibh ut arcu gravida sollicitudin.

Etiam sed commodo libero, vel eleifend augue. Praesent arcu tellus, commodo non pulvinar sed, elementum ac felis. Integer id venenatis mi. Pellentesque ut diam quis enim dapibus semper. Quisque ullamcorper, risus non molestie volutpat, orci odio convallis metus, sed bibendum odio felis eu nunc.

 

How many cup of coffee you should drink per day?

Vivamus fringilla euismod pharetra. Proin cursus gravida nunc a placerat. Nunc nec sollicitudin nibh. Sed vel elementum lectus. Nunc nec congue quam, vitae varius massa. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce eu consectetur mi.

 

 

Vestibulum et euismod nulla. Fusce quam nulla, tincidunt ac dignissim porta, facilisis id turpis. Ut viverra pharetra massa, et auctor orci convallis sit amet. Nullam eu vulputate elit. Fusce nunc purus, hendrerit vitae est vitae, feugiat consectetur urna. Praesent eget nisl at nibh tincidunt gravida vitae sit amet nibh.

 

Listening sounds like a ridiculous characteristic for mentoring, but genuinely being invested and interested in people, meeting them for cups of coffee and spending time with people, and using the network I've been very lucky to build up to help others are all things I do to help others.
Sinead Burke

Malesuada vel finibus necDonec eu dolor erat.

Morbi purus augue, varius at enim. Morbi molestie cursus dolor, nec lacinia velit dictum eget. Cras tortor nisi, porttitor eget malesuada ac, vestibulum non justo. Integer vel molestie libero. Quisque eget sagittis enim, ut volutpat velit. Donec purus nisi, pharetra at consequat at, venenatis vel lectus.

Proin viverra consectetur felis, a accumsan felis tincidunt ut. Ut cursus lacus sed pulvinar viverra. Duis eu magna vestibulum risus dignissim condimentum quis sed nulla. Duis iaculis purus vel vestibulum facilisis. Sed gravida viverra dui pulvinar condimentum. Suspendisse eget eros at ipsum pulvinar pellentesque. Etiam ac nibh ut arcu gravida sollicitudin.

Etiam sed commodo libero, vel eleifend augue. Praesent arcu tellus, commodo non pulvinar sed, elementum ac felis. Integer id venenatis mi. Pellentesque ut diam quis enim dapibus semper. Quisque ullamcorper, risus non molestie volutpat, orci odio convallis metus, sed bibendum odio felis eu nunc.

 

Benefits of drinking coffee

Vivamus fringilla euismod pharetra. Proin cursus gravida nunc a placerat. Nunc nec sollicitudin nibh. Sed vel elementum lectus. Nunc nec congue quam, vitae varius massa. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce eu consectetur mi.

 

 

Vestibulum et euismod nulla. Fusce quam nulla, tincidunt ac dignissim porta, facilisis id turpis. Ut viverra pharetra massa, et auctor orci convallis sit amet. Nullam eu vulputate elit. Fusce nunc purus, hendrerit vitae est vitae, feugiat consectetur urna. Praesent eget nisl at nibh tincidunt gravida vitae sit amet nibh.

 

Listening sounds like a ridiculous characteristic for mentoring, but genuinely being invested and interested in people, meeting them for cups of coffee and spending time with people, and using the network I've been very lucky to build up to help others are all things I do to help others.
Sinead Burke

Malesuada vel finibus necDonec eu dolor erat.

Morbi purus augue, varius at enim. Morbi molestie cursus dolor, nec lacinia velit dictum eget. Cras tortor nisi, porttitor eget malesuada ac, vestibulum non justo. Integer vel molestie libero. Quisque eget sagittis enim, ut volutpat velit. Donec purus nisi, pharetra at consequat at, venenatis vel lectus.

Proin viverra consectetur felis, a accumsan felis tincidunt ut. Ut cursus lacus sed pulvinar viverra. Duis eu magna vestibulum risus dignissim condimentum quis sed nulla. Duis iaculis purus vel vestibulum facilisis. Sed gravida viverra dui pulvinar condimentum. Suspendisse eget eros at ipsum pulvinar pellentesque. Etiam ac nibh ut arcu gravida sollicitudin.

Etiam sed commodo libero, vel eleifend augue. Praesent arcu tellus, commodo non pulvinar sed, elementum ac felis. Integer id venenatis mi. Pellentesque ut diam quis enim dapibus semper. Quisque ullamcorper, risus non molestie volutpat, orci odio convallis metus, sed bibendum odio felis eu nunc.

 

VSC中clang-format设置函数括号风格

目前发现一个问题在通过clang-format保存自动格式化时,函数的括号风格老是变化,一会是后置风格,一会是另起一行,如下所示:
风格1:

void fun(void){

}

风格2:

void fun(void)
{

}

本人想统一为风格1,无耐在VSC的UI里面各种参数尝试无果,于是找到官网:

ClangFormatStyleOptions

找到相关的设置:

BraceWrapping (BraceWrappingFlags)
Control of individual brace wrapping cases.

If BreakBeforeBraces is set to BS_Custom, use this to specify how each individual brace case should be handled. Otherwise, this is ignored.

# Example of usage:
BreakBeforeBraces: Custom
BraceWrapping:
  AfterEnum: true
  AfterStruct: false
  SplitEmptyFunction: false
  afterFunction: true

其中设置函数后括号风格的:

bool AfterFunction Wrap function definitions.

true:
void foo()
{
  bar();
  bar2();
}

false:
void foo() {
  bar();
  bar2();
}

将以上的配置添加到.clang-format 文件中,放到VSC工程的根目录下,才能生效