Programando u-blox NINA-W102 com NuttX - Acesso GPIO connectado ao LED
$sudo apt install \ bison flex gettext texinfo libncurses5-dev libncursesw5-dev \ gperf automake libtool pkg-config build-essential gperf genromfs \ libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils-dev libelf-dev \ libexpat-dev gcc-multilib g++-multilib picocom u-boot-tools util-linux
Nota 1: O NuttX utiliza um sistema de build semelhante ao do Kernel do Linux (https://www.kernel.org/doc/html/latest/kbuild/index.html). Ele utiliza o kconfig-frontends como seu sistema de configuração. O repositório tools.git é utilizado para instalar este pacote. Porém se você estiver usando o Ubuntu 19.10 ou mais recente, estas distribuições já contém o pacote, mas de qualquer forma, instale.$ sudo apt-get install kconfig-frontends
Nota 2: Outra dependência para o processo do NuttX com o ESP32 é o ESP-IDF (Espressif IoT Development Framework). Este framework é nativo do ESP e mantido pela Espressif. Ele compreende um conjunto de códigos como drivers, APIs, scripts, ferramental para compilar e fazer upload do firmware e o FreeRTOS customizado. Neste ponto, uma observação conceitual é muito importante, o NuttX não usa o FreeRTOS em nenhuma camada interna, apenas algumas ferramentas auxiliares que compõem o IDF serão utilizadas para geração do binário e gravação.
Download do NuttX
$ mkdir nuttx
$ cd nuttx
$ git clone https://github.com/apache/incubator-nuttx.git nuttx
$ git clone https://github.com/apache/incubator-nuttx-apps apps
O Ubuntu e o Debian ainda fornecem o Python 2.7 como o interpretador padrão, mas alguns
pacotes necessários podem estar faltando para distribuições mais recentes. Python 3 é
recomendado e pode ser instalado da seguinte maneira:
$ sudo apt-get install python3 python3-pip
python3-setuptool$sudo update-alternatives --install /usr/bin/python python /usr/bin/python3
Instale agora o ESP-IDF (ESP32 TOOLS, LIBS, ETC) manualmente
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-setup.html
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#get-started-get-esp-idf
osboxes@osboxes:~$ cd esp/
osboxes@osboxes:~/esp$ cd esp-idf/
osboxes@osboxes:~/esp/esp-idf$ ./install.sh
Detecting the Python interpreter
Checking "python" ...
/home/osboxes/esp/esp-idf/tools/detect_python.sh: line 16: python: command not found
Checking "python3" ...
Python 3.8.5
"python3" has been detected
Installing ESP-IDF tools
Installing tools: xtensa-esp32-elf, xtensa-esp32s2-elf, xtensa-esp32s3-elf, riscv32-esp-elf, esp32ulp-elf, esp32s2ulp-elf, openocd-esp32
Installing xtensa-esp32-elf@esp-2020r3-8.4.0
Downloading xtensa-esp32-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz to /home/osboxes/.espressif/dist/xtensa-esp32-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz.tmp
Done
Extracting /home/osboxes/.espressif/dist/xtensa-esp32-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz to /home/osboxes/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0
Installing xtensa-esp32s2-elf@esp-2020r3-8.4.0
Downloading xtensa-esp32s2-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz to /home/osboxes/.espressif/dist/xtensa-esp32s2-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz.tmp
Done
.
.
.
$cd nuttx
$make -C tools/esp32/ ${HOME}/esp/esp-idf
Após a instalação do IDF, ou caso já possua o IDF instalado, execute oseguinte comando para ativar o ambiente virtual que foi configurado nainstalação. Sempre que for realizar o build do NuttX, será necessárioativar este ambiente.$. ${HOME}/esp/esp-idf/export.sh
No presente momento, o NuttX utiliza 2 binários gerados através doIDF: o bootloader e a tabela de partição. Ainda dentro do diretórionuttx/, faça o download destes binários pré configurados:
Mantenha-se no diretório do NuttX e execute o script de configuração para criar um arquivo de configuração para o ESP32.
osboxes@osboxes:~/nuttx/nuttx$ makeCreate .versionCreate version.hLN: include/arch/board to /home/osboxes/nuttx/nuttx/boards/xtensa/esp32/esp32-devkitc/includemake[1]: Entering directory '/home/osboxes/nuttx/nuttx/libs/libxx'make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/libs/libxx'make[1]: Nothing to be done for 'dirlinks'. make[1]: Entering directory '/home/osboxes/nuttx/nuttx/boards'make[1]: Entering directory '/home/osboxes/nuttx/nuttx/openamp'make[1]: Nothing to be done for 'dirlinks'. make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/boards' make[1]: Nothing to be done for 'dirlinks'.make[2]: Entering directory '/home/osboxes/nuttx/apps/platform'make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/openamp' make[1]: Entering directory '/home/osboxes/nuttx/apps' LN: platform/board to /home/osboxes/nuttx/apps/platform/dummymake[2]: Entering directory '/home/osboxes/nuttx/nuttx/boards/xtensa/esp32/common'make[2]: Leaving directory '/home/osboxes/nuttx/apps/platform' make[1]: Leaving directory '/home/osboxes/nuttx/apps' make[1]: Entering directory '/home/osboxes/nuttx/nuttx/boards' make[2]: Nothing to be done for 'context'.make[1]: Nothing to be done for 'context'.make[2]: Leaving directory '/home/osboxes/nuttx/nuttx/boards/xtensa/esp32/common' make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/boards' make[1]: Entering directory '/home/osboxes/nuttx/nuttx/fs' make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/fs'make[2]: Entering directory '/home/osboxes/nuttx/apps'make[1]: Entering directory '/home/osboxes/nuttx/apps'...make[3]: Leaving directory '/home/osboxes/nuttx/apps/system/readline'make[2]: Leaving directory '/home/osboxes/nuttx/apps'IN: /home/osboxes/nuttx/apps/libapps.a -> staging/libapps.amake[1]: Leaving directory '/home/osboxes/nuttx/apps'make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/fs'make[1]: Entering directory '/home/osboxes/nuttx/nuttx/fs' make[1]: 'libfs.a' is up to date.make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/binfmt'make[1]: Entering directory '/home/osboxes/nuttx/nuttx/binfmt' make[1]: 'libbinfmt.a' is up to date.make[2]: 'libboard.a' is up to date.make[1]: Entering directory '/home/osboxes/nuttx/nuttx/arch/xtensa/src' make[2]: Entering directory '/home/osboxes/nuttx/nuttx/boards/xtensa/esp32/common'CP: nuttx.hexmake[2]: Leaving directory '/home/osboxes/nuttx/nuttx/boards/xtensa/esp32/common' LD: nuttx make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/arch/xtensa/src' CP: nuttx.binosboxes@osboxes:~/nuttx/nuttx$
**Este binário não tem os cabeçalhos com as informações que o bootloader do ESP32 espera encontrar, então ele deve ser removido:
$ rm nuttx.bin
E um novo binário deverá ser gerado a partir do arquivo ELF chamado “nuttx”. Para isso, é necessário usar o script esptool.py para gerar este arquivo:
esptool.py --chip esp32 elf2image --flash_mode dio --flash_size 2MB -o ./nuttx.bin nuttx
$ make menuconfig
.config - NuttX/x86_64 Configuration────────────────────────────────────────────────────────────────────────────────────┌───────────────────────── NuttX/x86_64 Configuration ──────────────────────────┐│ Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty ││ submenus ----). Highlighted letters are hotkeys. Pressing <Y> includes, ││ <N> excludes, <M> modularizes features. Press <Esc><Esc> to exit, <?> for ││ Help, </> for Search. Legend: [*] built-in [ ] excluded <M> module < > ││ ┌───────────────────────────────────────────────────────────────────────────┐ ││ │ Build Setup ---> │ ││ │ System Type ---> │ ││ │ Board Selection ---> │ ││ │ RTOS Features ---> │ ││ │ Device Drivers ---> │ ││ │ Networking Support ---> │ ││ │ Crypto API ---> │ ││ │ File Systems ---> │ ││ │ Graphics Support ---> │ ││ │ Memory Management ---> │ ││ │ Audio Support ---> │ ││ │ Video Support ---> │ ││ │ Wireless Support ---> │ ││ │ Binary Loader ---> │ ││ │ Library Routines ---> │ ││ │ Open Asymmetric Multi Processing ---> │ ││ │ Application Configuration ---> │ ││ └───────────────────────────────────────────────────────────────────────────┘ │├───────────────────────────────────────────────────────────────────────────────┤│ <Select> < Exit > < Help > < Save > < Load > │└───────────────────────────────────────────────────────────────────────────────┘Make menuconfig customiza o que deseja adicionar/retirar na placa. Por exemplo, permite adicionar os drivers de um determinado periférico, adicionar mensagens de debug, etc.
Após compilar, será gerado um BIN, o mesmo deve ser gravado no UBLOX NINA W102, via FLASHTOOLS, junto com partitions.bin e bootloader.bin.
Pode também ser utilizado esptools
TESTANDO NO NINA W102Abra então o TERATERM (115200,N,8.1)
Estando no diretório do nuttx, limpe a sua configuração atual, carregue a configuração para o ESP32 com o nsh (NuttX shell) e por fim entre no menu de configuração através do comando a seguir:
$ make distclean
$ ./tools/configure.sh esp32-devkitc:nsh
$ make menuconfig
osboxes@osboxes:~/nuttx/nuttx$ ./tools/configure.sh esp32-devkitc:nsh Copy files Select CONFIG_HOST_LINUX=y Refreshing... make[1]: Entering directory '/home/osboxes/nuttx/nuttx' make[2]: Entering directory '/home/osboxes/nuttx/nuttx/boards' make[2]: Leaving directory '/home/osboxes/nuttx/nuttx/boards' make[2]: Entering directory '/home/osboxes/nuttx/apps' make[3]: Entering directory '/home/osboxes/nuttx/apps/platform' make[3]: Leaving directory '/home/osboxes/nuttx/apps/platform' make[3]: Entering directory '/home/osboxes/nuttx/apps/builtin' make[3]: Leaving directory '/home/osboxes/nuttx/apps/builtin' make[2]: Leaving directory '/home/osboxes/nuttx/apps' make[2]: Entering directory '/home/osboxes/nuttx/nuttx/graphics' make[3]: Entering directory '/home/osboxes/nuttx/nuttx/graphics/nxglib' make[3]: Leaving directory '/home/osboxes/nuttx/nuttx/graphics/nxglib' make[3]: Entering directory '/home/osboxes/nuttx/nuttx/graphics/nxglib' make[3]: Leaving directory '/home/osboxes/nuttx/nuttx/graphics/nxglib' make[3]: Entering directory '/home/osboxes/nuttx/nuttx/graphics/nxglib' make[3]: Leaving directory '/home/osboxes/nuttx/nuttx/graphics/nxglib' make[2]: Leaving directory '/home/osboxes/nuttx/nuttx/graphics' make[2]: Entering directory '/home/osboxes/nuttx/nuttx/arch/xtensa/src' make[2]: Nothing to be done for 'clean_context'. make[2]: Leaving directory '/home/osboxes/nuttx/nuttx/arch/xtensa/src' make[1]: Leaving directory '/home/osboxes/nuttx/nuttx' LN: include/arch to arch/xtensa/include LN: include/arch/board to /home/osboxes/nuttx/nuttx/boards/xtensa/esp32/esp32-devkitc/include LN: include/arch/chip to arch/xtensa/include/esp32 LN: arch/xtensa/src/board to /home/osboxes/nuttx/nuttx/boards/xtensa/esp32/esp32-devkitc/../common LN: arch/xtensa/src/board/board to /home/osboxes/nuttx/nuttx/boards/xtensa/esp32/esp32-devkitc/src LN: arch/xtensa/src/chip to arch/xtensa/src/esp32 LN: /home/osboxes/nuttx/nuttx/drivers/platform to /home/osboxes/nuttx/nuttx/boards/xtensa/esp32/esp32-devkitc/../drivers make[1]: Entering directory '/home/osboxes/nuttx/nuttx/libs/libxx' make[1]: Nothing to be done for 'dirlinks'. make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/libs/libxx' make[1]: Entering directory '/home/osboxes/nuttx/nuttx/boards' make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/boards' make[1]: Entering directory '/home/osboxes/nuttx/nuttx/openamp' make[1]: Nothing to be done for 'dirlinks'. make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/openamp' make[1]: Entering directory '/home/osboxes/nuttx/apps' make[2]: Entering directory '/home/osboxes/nuttx/apps/platform' LN: platform/board to /home/osboxes/nuttx/apps/platform/dummy make[2]: Leaving directory '/home/osboxes/nuttx/apps/platform' make[1]: Leaving directory '/home/osboxes/nuttx/apps' make[1]: Entering directory '/home/osboxes/nuttx/apps' make[2]: Entering directory '/home/osboxes/nuttx/apps/canutils' mkkconfig in /home/osboxes/nuttx/apps/canutils make[2]: Leaving directory '/home/osboxes/nuttx/apps/canutils' make[2]: Entering directory '/home/osboxes/nuttx/apps/examples' mkkconfig in /home/osboxes/nuttx/apps/examples make[2]: Leaving directory '/home/osboxes/nuttx/apps/examples' make[2]: Entering directory '/home/osboxes/nuttx/apps/fsutils' mkkconfig in /home/osboxes/nuttx/apps/fsutils make[2]: Leaving directory '/home/osboxes/nuttx/apps/fsutils' make[2]: Entering directory '/home/osboxes/nuttx/apps/gpsutils' mkkconfig in /home/osboxes/nuttx/apps/gpsutils make[2]: Leaving directory '/home/osboxes/nuttx/apps/gpsutils' make[2]: Entering directory '/home/osboxes/nuttx/apps/graphics' mkkconfig in /home/osboxes/nuttx/apps/graphics make[2]: Leaving directory '/home/osboxes/nuttx/apps/graphics' make[2]: Entering directory '/home/osboxes/nuttx/apps/industry' mkkconfig in /home/osboxes/nuttx/apps/industry make[2]: Leaving directory '/home/osboxes/nuttx/apps/industry' make[2]: Entering directory '/home/osboxes/nuttx/apps/interpreters' mkkconfig in /home/osboxes/nuttx/apps/interpreters make[2]: Leaving directory '/home/osboxes/nuttx/apps/interpreters' make[2]: Entering directory '/home/osboxes/nuttx/apps/netutils' mkkconfig in /home/osboxes/nuttx/apps/netutils make[2]: Leaving directory '/home/osboxes/nuttx/apps/netutils' make[2]: Entering directory '/home/osboxes/nuttx/apps/system' make[3]: Entering directory '/home/osboxes/nuttx/apps/system/libuv' mkkconfig in /home/osboxes/nuttx/apps/system/libuv make[3]: Leaving directory '/home/osboxes/nuttx/apps/system/libuv' mkkconfig in /home/osboxes/nuttx/apps/system make[2]: Leaving directory '/home/osboxes/nuttx/apps/system' make[2]: Entering directory '/home/osboxes/nuttx/apps/testing' mkkconfig in /home/osboxes/nuttx/apps/testing make[2]: Leaving directory '/home/osboxes/nuttx/apps/testing' make[2]: Entering directory '/home/osboxes/nuttx/apps/wireless' make[3]: Entering directory '/home/osboxes/nuttx/apps/wireless/bluetooth' mkkconfig in /home/osboxes/nuttx/apps/wireless/bluetooth make[3]: Leaving directory '/home/osboxes/nuttx/apps/wireless/bluetooth' make[3]: Entering directory '/home/osboxes/nuttx/apps/wireless/ieee802154' mkkconfig in /home/osboxes/nuttx/apps/wireless/ieee802154 make[3]: Leaving directory '/home/osboxes/nuttx/apps/wireless/ieee802154' mkkconfig in /home/osboxes/nuttx/apps/wireless make[2]: Leaving directory '/home/osboxes/nuttx/apps/wireless' mkkconfig in /home/osboxes/nuttx/apps make[1]: Leaving directory '/home/osboxes/nuttx/apps' # # configuration written to .config # osboxes@osboxes:~/nuttx/nuttx$
osboxes@osboxes:~/nuttx/nuttx$ make menuconfig
Para adicionar o driver para o LED, navegue em Device Drivers->LED Support e selecione LED Driver e Generic Lower Half LED Driver (pressione y). Neste passo você está adicionando o driver para o LED.
Retorne ao menu inicial através de ‘Exit’. Basta usar as setas laterais e ‘Enter’.
Por fim, para adicionar o exemplo navegue em Application Configuration->Examples e selecione Led Driver Example.
* LED * * This is an externally connected LED used for testing. */ #define GPIO_LED1 33
$ make
osboxes@osboxes:~/nuttx/nuttx$ make make[1]: Entering directory '/home/osboxes/nuttx/nuttx/tools' make[1]: Leaving directory '/home/osboxes/nuttx/nuttx/tools' make[1]: Entering directory '/home/osboxes/nuttx/nuttx' make[2]: Entering directory '/home/osboxes/nuttx/nuttx/boards' make[2]: Leaving directory '/home/osboxes/nuttx/nuttx/boards' make[2]: Entering directory '/home/osboxes/nuttx/apps' make[3]: Entering directory '/home/osboxes/nuttx/apps/platform' make[3]: Leaving directory '/home/osboxes/nuttx/apps/platform' make[3]: Entering directory '/home/osboxes/nuttx/apps/builtin'
Sobre a SMARTCORE
Nenhum comentário:
Postar um comentário