quinta-feira, 10 de dezembro de 2020

U-BLOX NINA B112/302 - UTILIZANDO RASPBERRY COMO GRAVADOR/DEBUGGER

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:

reset init
reset halt
nrf5 mass_erase
set WORKAREASIZE 0x4000
program c:/openOCD/bin/s132_nrf52_2.0.1_softdevice.hex verify
program c:/openOCD/bin/led_switch.ino.hex verify
reset run
exit

CONFIGURANDO PINOS NO RASPBERRY




Dúvidas:

 

Sobre a SMARTCORE

A SmartCore fornece módulos para comunicação wireless, biometria, conectividade, rastreamento e automação.
Nosso portifólio inclui modem 2G/3G/4G/NB-IoT/Cat.M, satelital, módulos WiFi, Bluetooth, GNSS / GPS, Sigfox, LoRa, leitor de cartão, leitor QR code, mecanismo de impressão, mini-board PC, antena, pigtail, LCD, bateria, repetidor GPS e sensores.
Mais detalhes em www.smartcore.com.br

 

Nenhum comentário:

Postar um comentário