Adafruit Fruit Jam

The Adafruit Fruit Jam [1] is a single board computer based on the RP2350B, the 80-pin version of Raspberry Pi's RP2350 microcontroller:

FruitJam.jpg

The board is 85.7 x 54.0 mm and is based on the Raspberry Pi RP2350B running at 150MHz, with 16MB of flash, 520KB of on-chip SRAM, and 8MB of PSRAM. It includes a wide selection of peripherals including: a DVI port that can drive an HDMI display using the RP2350's High Speed Transmit (HSTX) peripheral, two USB-A ports for a keyboard, mouse, or game controller, a Micro SD Card, a TLV320DAC3100 capable of driving an I2S stereo headphone and mono loudspeaker, an ESP32-C6 for WiFi and Internet connectivity, five NeoPixels, and three switches.

It's supplied with two blank PCBs with appropriate cutouts so they can be used as front and back panels, and Adafruit have also released a 3D printed snap-on enclosure [2].

When Adafruit first announced the Fruit Jam I thought it would make an excellent basis for a complete stand-alone Lisp computer, running uLisp, with its own keyboard and display. I'm still working on that, but in the meantime have added support for the Fruit Jam to the ARM version of uLisp.

Installing uLisp from the Arduino IDE

Install the Raspberry Pi Pico/RP2040/RP2350 core

  • Add the following URL to the Additional Boards Manager URLs list in the Arduino IDE Preferences dialog box:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
  • In the Arduino IDE search for the Raspberry Pi Pico/RP2040/RP2350 core in Boards Manager and install it. I used version 5.0.0.
  • Select Raspberry Pi RP2040 from the Board menu, and Adafruit Fruit Jam RP2350 from the submenu.
  • Set Flash Size to the option 16MB (Sketch: 8MB, FS: 8MB).

This option allocates 8MB for use by LittleFS for use with save-image.

  • Leave USB Stack set to Pico SDK.
  • Set CPU Architecture to ARM or RISC-V to choose which core you want to use.

You can leave all the other options at their defaults.

Using PSRAM

  • If you want to use the PSRAM with uLisp uncomment the #define BOARD_HAS_PSRAM in the ARDUINO_ADAFRUIT_FRUITJAM_RP2350 section of the Platform specific settings at the start of the uLisp source.
  • Because garbage collections take over a second with 8 MB of PSRAM I also recommend commenting out the printfreespace option as follows:
// #define printfreespace

Otherwise there's a delay before the uLisp prompt is printed each time while the free space is calculated.

Note: Currently using PSRAM with uLisp isn't compatible with using the HDMI graphics output.

Using Micro SD cards

  • To use the SD card interface on the Adafruit Fruit Jam board uncomment this line at the start of the uLisp source before uploading uLisp:
#define sdcardsupport

Once you've uploaded uLisp you can check it's working by using the (directory) command to list the files on the SD card.

Upload uLisp

  • Download release 4.8f or later of the ARM version of uLisp from the Download uLisp page.
  • Select the board's USB port from the Port menu, or UF2 Board if that option is shown.
  • Upload uLisp to the board.

When you first plug in the Fruit Jam the five NeoPixels will light up in different colours. Once you've installed uLisp they will turn off if you disconnect and reconnect the USB-C connector.

Using uLisp

  • You may need to select the board's USB port from the Port menu again.
  • Select Serial Monitor from the Tools menu.
  • Enter Lisp commands.

Putting the board into upload mode

If the upload fails you may need to put the board into upload mode:

  • Press and hold the boot button, labelled Button #1.
  • Press the RESET button.
  • Release Button #1.

The upload should then continue to completion.

Error on save-image

If when you call save-image you get the error;

Error: 'save-image' problem saving to LittleFS

the most likely explanation is that you didn't set the Flash Size option to the appropriate value to reserve memory for LittleFS before uploading uLisp.

P2350-E9 Errata

A bug has been reported in the current A2 batch of RP2350 chips that means that in some cases when an input pin is being driven by a weak (high impedance) input, it may not read properly. There are workarounds for most practical applications; see the RP2350-E9 Errata for more details.

Using the Adafruit Fruit Jam board

Pinout

The following diagram shows the main board connections:

FruitJamPins.png

For a full pinout see Adafruit Fruit Jam RP2350

LED

The Fruit Jam has a red LED connected to digital pin 29 which you can flash with the following program:

(defun blink (&optional x)
  (pinmode :led-builtin t)
  (digitalwrite :led-builtin x)
(delay 1000) (blink (not x)))

Run it by typing:

(blink)

All pins can also be used for analogue (PWM) output, so you can pulsate the LED slowly on and off with the program:

(defun pulse ()
  (let (down)
    (loop
     (dotimes (x 256) 
       (delay 5) 
       (analogwrite :led-builtin (if down (- 255 x) x)))
(setq down (not down)))))

Run it by typing:

(pulse)

Exit from either program by entering ~.

NeoPixels

The Fruit Jam has five NeoPixel RGB LEDs connected to pin 32. You can control these using the ARM NeoPixel driver using assembler or the NeoPixel extension.

Analogue inputs

The Fruit Jam board provides six analogue inputs. Pin 40 (A0) is available on the 3-pin JST-H connector together with VCC and GND at bottom left of the Fruit Jam board, and pins 41 (A1) to 45 (A5) are available on the 16-pin header socket. They have 12 bit resolution.

Analogue outputs

You can generate an analogue output using PWM on any of the digital pins.

Serial

The Fruit Jam board has one accessible serial port: Serial1 on pin numbers 8 (TX) and 9 (RX).

SPI

The Fruit Jam board has two SPI ports. SPI0 is used for the SD card interface and is on pin numbers 36 (MISO), 35 (MOSI), 34 (SCK), and 39 (SS). SPI1 is available on pin numbers 28 (MISO), 31 (MOSI), 30 (SCK), and 46 (SS).

I2C

The Fruit Jam board has one accessible I2C port on pins 20 (SDA) and 21 (SCL). You can connect I2C devices using the STEMMA QT connector, or on the appropriate pins on the 16-pin header socket.

You can verify that the I2C port is working by connecting an I2C device to the STEMMA QT connector, or to SDA, SCL, 3V, and G on the socket header, and running the following scan program:

(defun scan () 
  (dotimes (p 127)
    (with-i2c (str p)
      (when str (print p)))))

To run it type

(scan)

It should print out the I2C address of the device on the bus.

5V USB output

You can use the USB-A outputs to provide 5V power to external devices, such as a display. To enable them you need to enable the PIN_5V_EN output on pin 11 with:

(pinmode 11 :output)
(digitalwrite 11 :high)

The current is limited to 5V 1A by a PTC resettable fuse.

HDMI display interface

The Fruit Jam board provides an HDMI display interface using the RP2350's High Speed Transmit (HSTX) peripheral that drives 4 lanes of differential data transmission without needing to overclock or use PIO.

Note: the HDMI display interface is currently not compatible with using PSRAM with uLisp.

The HDMI display supports the uLisp graphics extensions; see Graphics extensions:

FruitJamDisplay.jpg

The above display is Adafruit's 5" HDMI display without touch, with a resolution of 800x600 [3], running the Surface of rotation example.

To connect an HDMI display you need an HDMI to HDMI cable (not mini or micro HDMI).

  • Install the Adafruit DVI HSTX library from Manage Libraries… in the Arduino IDE.
  • If prompted to install other libraries click Install All.
  • Uncomment this line at the start of the uLisp source before uploading uLisp:
#define gfxsupport

By default uLisp is set up for a display resolution of 320x240. The Adafruit DVI HSTX library supports a range of display resolutions from 320x180 to 640x360, but because the display buffer is in RAM you will need to adjust the WORKSPACE setting to work with higher resolutions. For details of the supported display resolutions see HSTX supported resolutions.

The PIN_5V_EN output is automatically enabled if you specify an HDMI display with uLisp, allowing you to power a 5V display from one of the USB-A ports.

ARM and RISC-V assemblers

You can run uLisp on either the ARM or RISC-V core of the RP2350, and it's therefore possible to run either ARM or RISC-V machine code using the defcode function built in to uLisp.

There are both ARM and RISC-V assemblers that you can use to generate machine code from assembler programs; these are written in Lisp to make it easy to extend them or add new instructions. For more information see ARM assembler overview or RISC-V assembler overview.


  1. ^ Adafruit Fruit Jam - Mini RP2350 Computer on Adafruit.
  2. ^ Snap-on Enclosure for Adafruit Fruit Jam on Adafruit.
  3. ^ HDMI 5" Display Backpack - Without Touch on Adafruit.