Getting started with a JNZ Feb 2017

One of the features of the JeeNode Zero, is that it takes minimal effort to get started: hook it up via any USB serial interface, using any terminal emulator you like, and you’re all set to go.

Here’s a PL2303-based USB interface, connecting power (+5V/GND) and serial pins (RX/TX):

On the host side, you need a terminal emulator, such as Picocom or putty which can connect to a serial port and deal with lines coming back from the JNZ, ending in LF instead of CR+LF.

Picocom is available on MacOS (”brew install picocom”) and Linux (”sudo apt-get install picocom”). The trick is to add “--imap lfcrlf” when setting the baudrate:

picocom -b 115200 --imap lfcrlf /dev/your-usb-serial-device

It takes even less effort with Folie, which was designed specifically for use with Mecrisp Forth and which is available as an executable for several platforms, simply download and unzip. See the releases page on GitHub for details.

Whichever USB interface and terminal emulator you use, once connected and started up, you should be able to talk directly to the JeeNode Zero and see its interactive command prompt. No toolchain, no compiler, no uploads, nothing. Everything takes place on the JeeNode Zero.

The LED on the JNZ lights at power up, if Mecrisp and the default runtime code are present. The first thing to try would be to toggle the LED, and then repeat this a few times:

led iox! <enter>

Welcome to the JeeNode Zero and the world of 32-bit ARM with Mecrisp Forth!

We can make life easier by using a USB BUB or equivalent, which also controls the DTR pin:

This adds the ability to reset the JNZ from Folie, by simply hitting CTRL-C:

$ folie -r
Select the serial port:
1: /dev/cu.Bluetooth-Incoming-Port
2: /dev/cu.usbserial-A600dW4s
? 2
Enter '!help' for additional help, or ctrl-d to quit.
[connected to /dev/cu.usbserial-A600dW4s]
[...]
!reset
Mecrisp-Stellaris RA 2.3.3 with M0 core for STM32L053C8 by Matthias Koch
64 KB <jz4> 3B5E0728 ram/flash: 4960 21248 free ok.

It may not seem like much, but the JNZ does not have a built-in reset button, and resets are extremely common during Forth development (and nothing to be ashamed of, it’s a really convenient way to get control back) - CTRL-C without shifting your focus from keyboard-and-screen is in fact more convenient than a reset button.

For re-flashing, i.e. actual firmware uploading using the µC’s built-in ROM boot loader, you will need a BUB III (or a modified BUB II), which connects the RTS signal to pin 2 of the FTDI header (between GND and 5V). The good news is that you rarely need to reflash the JeeNode Zero - unless you lock yourself out of the command prompt, which is possible but uncommon.

At this point, it’s up to you what to do with the JNZ - perhaps read out some analog values?

Here is an example which uses the OLED and graphics driver that is pre-loaded in each JNZ:

As it so happens, the pinout of those very popular 128x64 OLED displays on eBay match the GND/VCC/SCL/SDA pins of the JNZ, which is why the OLED can be attached without even requiring any jumper wires. Just be sure to get the 4-pin I2C version of that OLED display.

We can verify that the OLED is detected at address $3C on the I2C bus by typing this:

i2c-init i2c. <enter>

Note the period at the end of “i2c.” - it’s part of the name. The output will be:

i2c-init i2c.
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3C -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --                         ok.

Showing that JeeLabs logo on the OLED is now a matter of entering this at the Forth prompt:

lcd-init show-logo <enter>

That’s it. Working! Not a very exciting result perhaps, but it’s an example of how having some drivers permanently present in the JNZ’s flash can turn it into a very simple interactively-programmable device. Coming up next: how to manage drivers and flash memory on a JNZ.

PS. Did you notice that the JeeNode Zero fits exactly in a mini breadboard? That’s intentional!

Weblog © Jean-Claude Wippler. Generated by Hugo.