Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpipico: fixed default SD card configuration. updated documentation. #1074

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions Kernel/platform/platform-rpipico/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ If you have an SD card reader, connect the SD card to the following pins:
Remember to also connect the SD card's GND to any Raspberry Pico GND pin and Vcc to
3.3V. Not 5V, or it won't work.

The console is accessible either via UART0 (at 115200 baud) or by connecting
the Pico up via USB to a PC, at which point it'll present itself as a standard
USB CDC serial device. Both work simultaneously although odd things can happen
if you type on both concurrently.
![Wiring diagram](doc/wiring.jpg)

**Note:** when using the USB console, you're unlikely to be able to connect
quickly enough after boot to see the startup messages. Most likely when you
connect, the Pico will be sitting waiting at the prompt to set the time. Press
RETURN a few times to get to the getty login prompt.
The console is accessible either via UART0 (at 115200 baud) or by connecting the Pico up via USB to a PC, at which point it'll present itself as a standard USB CDC serial device.

![Wiring diagram](doc/wiring.jpg)
**Note:** There's a small delay at startup if USB is connected to attempt to print full boot startup. There's a chance that startup message will still be missed. Either press return few times to get login prompt, or press `y` or `n` in case `fsck` is trying to ask you to check filesystem on startup. You can also try to increase `DEV_USB_INIT_TIMEOUT` if you're missing startup messages on powerup.

By default FUXIZ sets up 1 UART and 4 USB consoles. You can change it in `config.h` (see NUM_DEV_TTY_USB).

At startup system will automatically choose USB as boot console if it's connected, otherwise boot will print on UART0.

You can force certain configuration by passwing boot command line. For example: `tty=usb1,uart0,usb0`

## Building and installation

Expand All @@ -55,9 +55,11 @@ You need to install the [Raspberry Pi Pico SDK](https://www.raspberrypi.org/docu
cd Kernel/platform-rpipico
vi Makefile
# At this point, you need to edit the Makefile to tell it where the Raspberry Pi Pico SDK lives.
make image -j
```

To build flash image use `make image -j`
Or to build SD card image `make image-sd -j`

You should now end up with `build/fuzix.uf2` and `filesystem.uf2`. The `uf2`
files can be flashed onto the Pico in the usual way (i.e. connect it up as a
mass storage device and copy the files on). Alternatively, you can use OpenOCD
Expand All @@ -66,14 +68,15 @@ serial device which you can connect to. Alternatively, connect a terminal to
UART 0 on the Pico.

If you want to use an SD card, note that only filesystems up to 32MB are
supported. To format a file system, do this from the Fuzix shell:
supported.

Partition SD card on your computer using MBR partition scheme then create 32MB partition.
If using Linux or MacOS you can then copy `filesystem.img` onto the SD card using `dd` command.

```
$ mkfs -f /dev/hdb1 32 65535
dd if=filesystem.img of=/dev/sdN bs=512 seek=2048
```

The last argument is the filesystem size in 512-byte blocks.

The first thing you probably want to do is `stty erase '^?'` to make the DELETE
key in your terminal work properly. (Use the `levee` editor to add it to
`$HOME/.profile`.)
Expand Down
31 changes: 23 additions & 8 deletions Kernel/platform/platform-rpipico/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
#define CONFIG_H
#include "tusb_config.h"
/*
* Set this according to your SD card pins (default
* is the David Given arrangement).
* Set this according to your SD card pins
* CONFIG_RC2040
* SCK GPIO 14
* TX GPIO 15
* RX GPIO 12
* CS GPIO 13
* If Undefined
* SCK GPIO 2
* TX GPIO 3
* RX GPIO 4
* CS GPIO 5
*/

#undef CONFIG_RC2040


#define CONFIG_RC2040

/* Enable to make ^Z dump the inode table for debug */
#undef CONFIG_IDUMP
Expand Down Expand Up @@ -74,15 +81,23 @@ extern uint8_t progbase[USERMEM];
/* In this case, the default is the first TTY device */

#define TICKSPERSEC 200 /* Ticks per second */
/* We need a tidier way to do this from the loader */
/*
* Boot cmd line.
* cu [BOOTDEVICE] [tty=<TTYLIST>]
*
* <BOOTDEVICE> - use `hda` for built-in flash or `hdbX` for SD card, where X is partition number
* <TTYLIST> - list of TTY devices in order. If not specified system will
* map USB devices to tty0-4 and UART0 to tty5 if USB is connected. Or UART0 to tty0 etc if not.
* Example: `tty=usb1,uart0,usb0`
*/
#define CMDLINE NULL /* Location of root dev name */

#define BOOTDEVICENAMES "hd#"
#define SWAPDEV (swap_dev) /* dynamic swap */

/* Device parameters */
#define NUM_DEV_TTY_UART 1
#define NUM_DEV_TTY_USB 4
#define NUM_DEV_TTY_UART 1 /* min 1 max 1*/
#define NUM_DEV_TTY_USB 4 /* min 1 max 4. */
#define NUM_DEV_TTY (NUM_DEV_TTY_UART + NUM_DEV_TTY_USB)
#define DEV_USB_DETECT_TIMEOUT 5000 /* (ms) Total timeout time to detect USB host connection*/
#define DEV_USB_INIT_TIMEOUT 2000 /* (ms) Total timeout to try not swallow messages */
Expand Down
Loading