Gravando NINA B112 com RASPBERRY
O objetivo deste BLOG é demonstrar como é possível utilizar o Raspberry Pi Zero W (BCM2835 ) como gravador dos módulos U-BLOX NINA B112/B302
Roteiro Básico
Via Serial o SSH:
sudo apt install wget git autoconf libtool make pkg-config libusb-1.0-0 libusb-1.0-0-dev libhidapi-dev libftdi-dev telnet
git clone https://github.com/ntfreak/openocd
cd openocd
./bootstrap
./configure --enable-sysfsgpio --enable-bcm2835gpio --enable-cmsis-dap
make
cd ..
wget https://raw.githubusercontent.com/lupyuen/stm32bluepill-mynewt-sensor/nrf52/scripts/nrf52/swd-pi.ocd
Edite o swd-pi.ocd baixado
Comente as linhas (insira o prefixo #) para bcm2835gpio_peripheral_base e bcm2835gpio_speed_coeffs em Pi 4
Remova o comentário das linhas (remova o prefixo #) para bcm2835gpio_peripheral_base e bcm2835gpio_speed_coeffs para seu modelo de Raspberry Pi: Pi 1/2/3/4
# Select the Broadcom GPIO interface for Raspbery Pi interface bcm2835gpio ############################################################################### # Peripheral Base Address # For Pi 4 bcm2835gpio_peripheral_base 0xFE000000 # For Pi 2 and 3 # bcm2835gpio_peripheral_base 0x3F000000 # For Pi 1 # bcm2835gpio_peripheral_base 0x20000000 ############################################################################### # Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET # bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET # For Pi 4 bcm2835gpio_speed_coeffs 236181 60 # For Pi 3 BCM2837 (1200Mhz) # bcm2835gpio_speed_coeffs 194938 48 # For Pi 2 BCM2836 (900Mhz) # bcm2835gpio_speed_coeffs 146203 36 # For Pi 1 BCM2835 (700Mhz) # bcm2835gpio_speed_coeffs 113714 28 ############################################################################### # SWD Configuration # Assign each SWD line (SWCLK, SWDIO) to a Pi GPIO: (See https://pinout.xyz/ for Pi Header Pin Number to GPIO mapping) # Connect Pi Header Pin Number 38 (GPIO 20) to nRF52 SWCLK (Yellow wire) # Connect Pi Header Pin Number 40 (GPIO 21) to nRF52 SWDIO (Green wire) bcm2835gpio_swd_nums 20 21 # Assign SRST (Reset) line to a Pi GPIO: # Connect Pi Header Pin Number 12 (GPIO 18) to nRF52 RESET (White wire) bcm2835gpio_srst_num 18 # Connect Pi 3.3V (Red) and GND (Purple) to nRF52 VDD and GND ############################################################################### # Transport transport select swd ############################################################################### # Target set WORKAREASIZE 0 source [find target/nrf52.cfg] # Configure reset to use SRST line reset_config srst_only srst_nogate adapter_nsrst_delay 100 adapter_nsrst_assert_width 100 ############################################################################### # Execution init
Entre no prompt de comando ...
# Iniciar OpenOCD
sudo /home/pi/openocd/src/openocd \
-s /home/pi/openocd/tcl \
-d4 \
-f swd-pi.ocd
-d4 é opcional
Devemos ver o seguinte log ...
Open On-Chip Debugger 0.10.0+dev-00935-g31100927 (2019-09-25-18:38) ... Debug: 226 17 bitbang.c:496 bitbang_swd_read_reg(): OK DP read reg 0 = 2ba01477 Info : 235 17 adi_v5_swd.c:136 swd_connect(): SWD DPIDR 0x2ba01477 Debug: 236 17 arm_adi_v5.c:653 dap_dp_init(): nrf52.dap ... Debug: 534 670 gdb_server.c:3397 gdb_target_start(): starting gdb server for nrf52.cpu on 3333 Info : 535 670 server.c:311 add_service(): Listening on port 3333 for gdb connections Info : 536 670 server.c:311 add_service(): Listening on port 6666 for tcl connections Info : 537 670 server.c:311 add_service(): Listening on port 4444 for telnet connections Debug: 538 670 command.c:143 script_debug(): command - init init
Enquanto o OpenOCD está em execução, abra um segundo prompt de comando e digite ...
telnet localhost 4444
(desabilite qualquer firewall)
Execute os comandos necessários para gravar o U-BLOX NINA B112/302. Abaixo alguns exemplos:
CONFIGURANDO PINOS NO RASPBERRY
Dúvidas:
Referências:
https://www.u-blox.com/sites/default/files/NINA-B1_SIM_%28UBX-15026175%29.pdf
http://openocd.org/doc/pdf/openocd.pdf