Month: April 2020

Using Renesas RX63N with JLink on Linux

I want to test NuttX on RX65N but unfortunately I only found a RX63N board here in Brazil. The board is called RX63N RDK IoT Starter Kit and Part No.: YRDKRX63N-AWS

This board come with a Segger JLink embedded on it, so I decided to try JLinkExe program and it was detected correctly:

$ sudo JLinkExe
SEGGER J-Link Commander V6.46h (Compiled Jun 28 2019 17:19:57)
DLL version V6.46h, compiled Jun 28 2019 17:19:50

Connecting to J-Link via USB…O.K.
Firmware: J-Link OB RX6xx V1 compiled Jul 8 2013 19:14:58
Hardware version: V2.10
S/N: XXXXXXXXX
VTref=3.300V

Type "connect" to establish a target connection, '?' for help
J-Link>con
Please specify device / core. : ATSAML21G18
Type '?' for selection dialog
Device>RX63N
Please specify target interface:
J) JTAG (Default)
F) FINE
TIF>J
Device position in JTAG chain (IRPre,DRPre) : -1,-1 => Auto-detect
JTAGConf>
Specify target interface speed [kHz]. : 4000 kHz
Speed>
Device "RX63N" selected.
Connecting to target via JTAG
TotalIRLen = 8, IRPrint = 0x00C1
JTAG chain detection found 1 devices:
#0 Id: 0x1D005447, IRLen: 08, RX63N Core
Found Renesas RX63N device
Debugger authenticated successfully.
Endian: little
RX63N identified.
J-Link>savebin /tmp/upload.bin 0x0
Syntax: savebin , , (hex)
J-Link>savebin /tmp/upload.bin 0 40000
Opening binary file for writing… [/tmp/upload.bin]
Reading 262144 bytes from addr 0x00000000 into file…O.K.
J-Link>exit

The risk of designing OFF DATA SHEET

Ten years ago I was working for a Brazilian company that develops vehicle tracking devices. That company used to have a design house in Beijing, China and their hardware engineer/designer came from Motorola company. He was an award-winning designer at Motorola and had huge knowledge about electronics.

He developed a nice kind of industrial tablet using a Freescale (now NXP) microprocessor. And this tablet was using the Freescale audio codec SGTL5000, but he decided to create his own analog circuit for the audio codec, instead following the examples from the datasheet (there are about 3 or 4 reference circuits in the datasheet).

The audio quality from that tablet was good, but after some months when to product was already in production we received a lot of SGTL5000 that didn’t work well in the tablet. It was generating too much noise.

After some debugging we discovered that soldering this new audio codec chip in the development board the audio quality still good. Then for some reason the circuit designed by our hardware engineer didn’t work when some factory parameter has changed.

This same thing could happen to any other hardware component, always follow the datasheet. This Maxim AppNote/Tutorial is really good to explain this issue:

https://www.maximintegrated.com/en/design/technical-documents/tutorials/4/4429.html

Using nuttx i2c scan to detect MAX30100

I’m creating a NuttX driver for MAX30100 Pulse Oximeter Heart Rate sensor. At first my noticed the sensor wasn’t responding, then I searched in the Internet and discovered that the board model I was using has an issue:

https://www.teachmemicro.com/max30100-arduino-heart-rate-sensor/

They connected the pull-up resistor of SCL and SDA lines to 1.8V.

After fixing it I used the i2c scan and it worked:

nsh> i2c bus
BUS EXISTS?
Bus 1: YES

nsh> i2c dev 0x00 0x7f
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

nsh> i2c get -a 57 -r ff
READ Bus: 1 Addr: 57 Subaddr: ff Value: 11
nsh>

Automate vim line position to show nxstyle errors

This is how a create a automated process to move to the next lines where nxstyle error are reported (actual from last error to the first one direction).

First we need to run nxstyle in the file to be fixed:

$ ./tools/nxstyle arch/arm/src/stm32l4/stm32l4_usbdev.c 2>&1 | sed -e 's/.*usbdev.c://g' | sed -e 's/:.*//g' > /tmp/lines.txt

Then create a script (i.e: /home/alan/test.sh) to be executed when a key combination is pressed. It will read the above lines file from the last line to the first one and type that line on vim to move to that line:

#!/bin/bash
LINE=$(tail -1 /tmp/lines.txt)
cp /tmp/lines.txt /tmp/lines.txt.tmp
sed '$ d' /tmp/lines.txt.tmp > /tmp/lines.txt
rm -f /tmp/lines.txt.tmp
WID=`xdotool search "Terminal" | head -1`
xdotool windowactivate --sync $WID
xdotool type ":$LINE"
xdotool key Return

Finally edit teh xbindkeysrc to execute the above script when Alt+F7 is pressed:

$ vi ~/.xbindkeysrc
"/home/alan/test.sh"
    Alt + F7