Month: January 2022

Inserting TAB character into online forms

I was reviewing a NuttX RTOS PR (Pull Request) and facing a challenge: I want to suggest to change a text in a line from a Kconfig file that starts with two TABs characters, but pressing the keyboard tab key just move to the next page component.

Searching for a solution I discovered that GTK+ on Linux supports a feature similar to Windows to enter special characters in unicode symbols. On Windows if you press ALT and type 09 it will enter the TAB character (in fact you can use it to type any character, you can even create simple executables).

On Linux you need to enter this more complex sequence (otherwise it is not Linux) here:
Ctrl + Shift + u
type 9 and press Enter or Space

Source: https://superuser.com/questions/67934/typing-the-tab-character-in-browser-text-boxes

Using OpenOCD to Debug ESP32S3 Microcontroller

Compile the OpenOCD’s project:

$ git clone https://github.com/espressif/openocd-esp32
$ ./configure --program-prefix=esp32s3- --enable-dummy --enable-ftdi --enable-ftdi-oscan1 --enable-stlink --enable-ti-icdi --enable-ulink --enable-usb-blaster-2 --enable-ft232r --enable-vsllink --enable-xds110 --enable-osbdm --enable-opendous --enable-esp-usb-jtag --enable-aice --enable-usbprog --enable-rlink --enable-armjtagew --enable-cmsis-dap --enable-kitprog --enable-usb-blaster --enable-presto --enable-openjtag --enable-jlink
$ make
$ make install

This is the way I’m debugging ESP32-S3 using Espressif’s OpenOCD:

$ sudo esp32s3-openocd -c "set ESP_RTOS none" -c "set ESP32_ONLYCPU 1" -c "set ESP_FLASH_SIZE 0" -f board/esp32s3-builtin.cfg

Open a new terminal and run GDB:

$ xtensa-esp32s3-elf-gdb nuttx
GNU gdb (crosstool-NG esp-2021r2) 9.2.90.20200913-git
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=xtensa-esp32s3-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.

For help, type "help".
Type "apropos word" to search for commands related to "word"…
Reading symbols from nuttx…
(gdb) tar rem :3333
Remote debugging using :3333
0x420042ba in esp32s3_region_protection () at chip/esp32s3_region.c:91
91 {
(gdb) mon reset halt
JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
esp32s3.cpu0: Debug controller was reset.
esp32s3.cpu0: Core was reset.
esp32s3.cpu0: Target halted, PC=0x500000EF, debug_reason=00000000
Set GDB target to 'esp32s3.cpu0'
esp32s3.cpu0: Core was reset.
esp32s3.cpu0: Target halted, PC=0x40000400, debug_reason=00000000
esp32s3.cpu1: Debug controller was reset.
esp32s3.cpu1: Core was reset.
esp32s3.cpu1: Target halted, PC=0x40000400, debug_reason=00000000
(gdb) b __start
Breakpoint 1 at 0x40378750: file chip/esp32s3_start.c, line 190.
(gdb) c
Continuing.
esp32s3.cpu0: Target halted, PC=0x40378750, debug_reason=00000001
Set GDB target to 'esp32s3.cpu0'
esp32s3.cpu1: Target halted, PC=0x40043A40, debug_reason=00000000

Breakpoint 1, __start () at chip/esp32s3_start.c:190
190 {
(gdb) quit

Testing NuttX RTOS on Z80 Simulator

I decided to do a small test to see if we could run NuttX on Z80.

First I download and compiled to z80sim from here:
https://www.autometer.de/unix4fun/z80pack/ftp/

Then I installed the SDCC compile:

$ sudo apt install sdcc

Then on NuttX I configured to use the z80sim profile:

$ ./tools/configure.sh z80sim:nsh

It resulted on errors in the build system that I fixed and submitted to mainline:

https://github.com/apache/incubator-nuttx/pull/5233

After that the compilation starts, but it is failing because some files are not compatible with SDCC:

$ make
...
CC: clock/clock_initialize.c
/home/user/nuttxspace/nuttx/include/signal.h:333: error 97: SDCC cannot pass structure '_value' as function argument
/home/user/nuttxspace/nuttx/include/signal.h:428: error 97: SDCC cannot pass structure '_value' as function argument
/home/user/nuttxspace/nuttx/include/signal.h:428: error 97: SDCC cannot pass structure '_value' as function argument
/home/user/nuttxspace/nuttx/include/nuttx/sched.h:405: syntax error: token -> '}' ; column 3
make[1]: *** [Makefile:57: clock_initialize.rel] Error 1
make[1]: Leaving directory '/home/user/nuttxspace/nuttx/sched'
make: *** [tools/LibTargets.mk:59: sched/libsched.lib] Error 2

Let see if we get these files fixed and eventually get NuttX running on Z80 Simulator

Calculando digito verificador do EAN13

O cálculo do digito verificador é bem simples:

  1. Comece removendo o 13º digito (que é exatamente o dígito verificador que estamos querendo calcular/checar). Por exemplo: 6944853600540 ficará 694485360054
  2. Some da direita para esquerda apenas os dígitos impar: 4+0+6+5+4+9 e multiplique o resultado por 3: 28 * 3 = 84
  3. Agora some os números restantes (que estão nas posições pares) : 5+0+3+8+4+6 = 26. Some este resultado com o valor obtido anteriormente: 84+26 = 110
  4. O dígito verificador será o valor necessário para atingir o próximo número que é multiplo de dez, neste caso como o valor já é multiplo de 10, o dígito verificador será 0. Caso o resultado tivesse dado 109 o valor para se chegar ao número multiplo de 10 seria 1.

How to fix the apt fix-broken

If you are facing some unmet dependencies like that and the suggested “apt –fix-broken install” doesn’t work, then maybe this suggestion will help:

Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
ubuntu-desktop : Depends: libu2f-udev but it is not going to be installed
ubuntu-desktop-minimal : Depends: libu2f-udev but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

You should manually install the missing package, normally you will find it inside /var/cache/apt/archives otherwise you need to download it manually from Internet. In my case:

$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/libu2f-udev_1.1.10-3build1_all.deb
Selecting previously unselected package libu2f-udev.
(Reading database … 332193 files and directories currently installed.)
Preparing to unpack …/libu2f-udev_1.1.10-3build1_all.deb …
Unpacking libu2f-udev (1.1.10-3build1) over (1.1.10-3build1) …
Setting up libu2f-udev (1.1.10-3build1) …

Then finally a simple apt-get install -f finished the installation:

$ sudo apt-get install -f

Source: https://askubuntu.com/questions/141370/how-to-fix-a-broken-package-when-apt-get-install-f-does-not-work