Month: August 2021

Flashing STM32H745I-DISCO board

$ sudo openocd -f interface/stlink.cfg -f target/stm32h7x.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x08000000"
Open On-Chip Debugger 0.11.0+dev-00062-g6405d35f3-dirty (2021-05-15-10:34)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select '.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 1800 kHz
Info : STLINK V3J3M2 (API v3) VID:PID 0483:374E
Info : Target voltage: 3.274900
Info : stm32h7x.cpu0: hardware has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32h7x.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000340 msp: 0x24000ec8
Info : Device: STM32H74x/75x
Info : flash size probed value 2048
Info : STM32H7 flash has dual banks
Info : Bank (0) size is 1024 kb, base address is 0x08000000
Info : Padding image section 0 at 0x08017e10 with 16 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x08017e20 .. 0x0801ffff
auto erase enabled
wrote 97824 bytes from file nuttx.bin in 2.126441s (44.925 KiB/s)
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
^Cshutdown command invoked

Testing NuttX SoftAP on ESP32

These are the steps I used to get it working:

Configure, compile and flash the NuttX firmware on your ESP32:


$ ./tools/configure.sh esp32-devkitc:sta_softap
$ make download ESPTOOL_PORT=/dev/ttyUSB0

Then in the “nsh>” terminal execute this sequence:

nsh> ifup wlan1
ifup wlan1…OK
nsh> dhcpd_start wlan1
nsh> wapi psk wlan1 MyPassword 1
nsh> wapi essid wlan1 nuttxap 1
nsh> ifconfig
wlan0 Link encap:Ethernet HWaddr 8c:aa:b5:b5:aa:b0 at DOWN
inet addr:0.0.0.0 DRaddr:0.0.0.0 Mask:0.0.0.0

wlan1 Link encap:Ethernet HWaddr 8e:aa:b5:b5:aa:b0 at UP
inet addr:10.0.0.1 DRaddr:10.0.0.1 Mask:255.255.255.0

Now from your smartphone our laptop connect to the “nuttxap” WiFi.

Testing the new WiFi driver to ESP32

We are working in a new WiFi driver to ESP32 to make it more agnostic, but it is working fine:

nsh> wapi psk wlan0 MyPassword 3
[ 160.770000] [CPU1] esp_wifi_sta_password: WiFi station password=MyPassword len=8

nsh> wapi essid wlan0 MyRouter.4GHz 1
[ 199.290000] [CPU0] esp_wifi_send_event_to_supplicant: Sent 20 bytes from D->S
[ 199.290000] [CPU0] esp_event_post: Event: base=WIFI_EVENT id=3 data=0 data_size=0 tick5
[ 199.300000] [CPU1] esp_evt_work_cb: WiFi sta stop
[ 199.330000] [CPU0] esp_wifi_send_event_to_supplicant: Sent 20 bytes from D->S
[ 199.330000] [CPU0] esp_event_post: Event: base=WIFI_EVENT id=2 data=0 data_size=0 tick5
i 199.34[00 0 10]99 .[C34PU001]00 ]es p[C_ePvUt0]w oesrkp__cwibf:i _WsitFai esstas isdF
station ssid=ACA2021_2.4GHz len=14
[ 199.360000] [CPU0] esp_wifi_send_event_to_supplicant: Sent 412 bytes from D->S
[ 199.360000] [CPU0] sta_parse_rsn: sta_parse_rsn:4867
[ 199.360000] [CPU0] sta_parse_rsn: sta_parse_rsn:4867
es 199.370000] [CPU0] esp_wifi_send_event_to_su[p p1li9c9.a37nt0:0 0S0]en t[C P26U 1]by S
sid: WiFi station ssid=ACA2021_2.4GHz len=14
[ 199.380000] [CPU1] esp_wifi_sta_password: WiFi station password=Gargame1 len=8
[ 199.690000] [CPU1] esp_wifi_sta_mlme: assoc bssid is 08:7e:64:82:d3:20
[ 200.240000] [CPU0] esp_wifi_send_event_to_supplicant: Sent 151 bytes from D->S
[ 200.250000] [CPU1] esp_wifi_sta_set_private: sending eapol packet
[ 200.250000] [CPU0] esp_wifi_send_event_to_supplicant: Sent 20 bytes from D->S
[ 200.270000] [CPU0] esp_wifi_send_event_to_supplicant: Sent 185 bytes from D->S
[ 200.270000] [CPU1] esp_wifi_sta_set_private: sending eapol packet
200.280000] [CPU0] esp_wifi_send_event_to_supplicant: Sent 20 byt[e s 2f0r0.om2 8D0-0]
[CPU1] wlhexdump: key - wlhexdump(len=16):
[ 200.290000] [CPU1] wlhexdump: ae 39 46 d6 a2 36 9e 38 08 d5 91 34 4c 49 36 1e
[ 200.290000] [CPU1] esp_wifi_sta_password: alg=3 address= idx=0 set_tx=8 hw_index=4
[ 200.300000] [CPU1] wlhexdump: key - wlhexdump(len=16):
[ 200.310000] [CPU1] wlhexdump: ee 5d 00 67 d1 88 2a 30 40 c3 43 cc 35 67 c6 b1
[ 200.310000] [CPU1] esp_wifi_sta_password: alg=3 address= idx=2 set_tx=0 hw_index=1
[ 200.320000] [CPU1] esp_wifi_sta_password: auth is done
[ 200.380000] [CPU0] esp_event_post: Event: base=WIFI_EVENT id=4 data=0x3ffca360 data_si5
[ 200.380000] [CPU1] esp_evt_work_cb: WiFi sta connected

nsh> ifconfig
wlan0 Link encap:Ethernet HWaddr ac:67:b2:53:95:18 at UP
inet addr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0
         IPv4   TCP   UDP  ICMP                                                       
Received 000a 0000 0000 0000
Dropped 000a 0000 0000 0000
IPv4 VHL: 0000 Frg: 0000
Checksum 0000 0000 0000 ----
TCP ACK: 0000 SYN: 0000
RST: 0000 0000
Type 0000 ---- ---- 0000
Sent 0000 0000 0000 0000
Rexmit ---- 0000 ---- ----

nsh> renew wlan0

nsh> ifconfig
wlan0 Link encap:Ethernet HWaddr ac:67:b2:53:95:18 at UP
inet addr:192.168.0.17 DRaddr:192.168.0.1 Mask:255.255.255.0
         IPv4   TCP   UDP  ICMP                                                       
Received 000c 0000 0002 0000
Dropped 000a 0000 0000 0000
IPv4 VHL: 0000 Frg: 0000
Checksum 0000 0000 0000 ----
TCP ACK: 0000 SYN: 0000
RST: 0000 0000
Type 0000 ---- ---- 0000
Sent 0002 0000 0002 0000
Rexmit ---- 0000 ---- ----
nsh>
```

Abriu uma empresa? Cuidado com o golpe do Registro Dominio nirebr.com

É sempre assim: você abre uma empresa e começa a receber boletos para pagar, alguns são legítimos, mas muitos são pessoas e empresas querendo aplicar algum golpe (scam em inglês).

Vou reproduzir o email aqui para que pessoas desavisadas ou inexperientes não caiam no golpe:

Prezado(s) MINHA EMPRESA LTDA,

Segue anexo boleto referente cobrança da taxa de registro do domínio minhaempresa com br - vencimento no próximo dia 13 de Agosto.

O registro do nome minhaempresa representa a patenteação da empresa no mercado digital, através do Comitê Gestor da Internet no Brasil.

Essa taxa se refere à proteção jurídica e gestão do domínio contra uso indevido do termo e disputa de nome empresarial por terceiros.

Ao visualizar essa mensagem, caso o boleto esteja vencido, favor solicitar segunda via e evitar frustrações e transtornos financeiros através do link https://registre.br.com/

Atenciosamente,
Dep. Financeiro
Registro Domínio
brcom

Felizmente eles só mandaram o email e esqueceram de enviar o anexo e também não tentaram registrar o domínio, o que eu mesmo acabei fazendo. Eles acabaram me ajudando a lembra de registrar, rs.

Testing BLE on ESP32

nsh> bt bnep0 scan start
nsh> bt bnep0 scan stop
nsh> bt bnep0 scan get
Scan result:
addr: 5c:bd:a6:26:a3:9d type: 1
rssi: -88
response type: 2
advertiser data: 02 01 1a 0a ff c4 00 06 34 03 12 14 16 80 02 0a
d4 03 03 b9 fe 08 1b 00 2d 97 67 12 dd 78
addr: 5c:bd:a6:26:a3:9d type: 1
rssi: -86
response type: 2
advertiser data: 02 01 1a 0a ff c4 00 06 34 03 12 14 16 80 02 0a
d4 03 03 b9 fe 08 1b 00 2d 97 67 12 dd 78
addr: 5c:bd:a6:26:a3:9d type: 1
rssi: -88
response type: 4
advertiser data: 18 09 5b 4c 47 5d 20 77 65 62 4f 53 20 54 56 20
55 4d 37 32 37 30 50 53 41 02 0a d4
addr: 7f:b4:6b:4a:c6:94 type: 1
rssi: -94
response type: 0
advertiser data: 02 01 1a 02 0a 07 0a ff 4c 00 10 05 52 1c a8 f0
c1
addr: 7f:b4:6b:4a:c6:94 type: 1
rssi: -95
response type: 4
nsh>

Como assinar um PDF com e-CPF A1 no Linux

Recentemente tive que criar um e-CPF A1 e descobri que dá para assinar PDFs com ele usando o Linux.

O e-CPF foi emitido por uma empresa chamada AC CONSULTI BRASIL RFB (www.acconsultibrasil.com.br) que infelizmente só tem o software pra Windows pra gerar o e-CPF. Então tive que instalar uma máquina virtual com Windows só para poder gerar o e-CPF, lamentável!
A RFB deveria exigir que as empresas que emitem e-CPF tenham versões para Windows, Linux, Mac, Android e iOS.

Ela vai gerar um arquivo com uma extensão .pfx que é um conteiner “pkcs12” contendo a chave privada e o certificado.

Felizmente você pode usar este arquivo .pfx no Linux para assinar PDFs, basta baixar o “Portable Signer” deste site: http://portablesigner.sourceforge.net/

Rode e comando:

$ java -jar PortableSigner.jar

Ele é bem simples de usar, apenas escolha o arquivo PDF que vc quer assinar, escolha o seu .pfx e se quiser deixar visível que está certificado marque a opção: Append signature block.