Commit Graph

24 Commits

Author SHA1 Message Date
kay e75e3a20e6 Fix undefined `cs` variable
Attempting to compile without this fix results in this error
```
main.c:226:9: error: 'cs' undeclared (first use in this function)
  226 |         cs = readbyte_blocking();
      |         ^~
```
This fix declares `cs` as a `uint8_t`. Tested and was able to read/write to a MX25L6406E and MX25L3206E
2024-02-11 20:36:22 +02:00
Riku Viitanen 3d573a01c4 reformatting
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2024-02-07 20:54:23 +02:00
Riku Viitanen 556f99e36f refactoring, fix grammar bug
Should fix bug: https://codeberg.org/libreboot/lbmk/issues/182

Declaration aren't allowed immediately after labels. Some compilers
are apparently more strict about this, mine didn't even warn about it.

Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2024-02-07 20:22:38 +02:00
Riku Viitanen bdcb6f6f55 update readme
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2024-01-31 23:01:32 +02:00
Riku Viitanen 377d9f2d52 Document multiple Chip Selects
Flashrom -> Flashprog. Currently only flashprog supports multiple CS.

Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2024-01-28 00:05:10 +02:00
Riku Viitanen 1dc9bb96e4 Enable pull-ups on unused chip selects
When SPI interface is enabled, no chip selects should be floating.
That can cause issues, for example if such a pin is connected to a
flash chip with no pull-ups on board.

So, enable RP2040's internal pull-ups on those pins.

Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2024-01-27 23:59:02 +02:00
Riku Viitanen 6301fbf3ed add support for multiple chip selects
now, GP5..8 are available as cs=0..3
GP5 is still the default one, which is defaulted to on power-up.

Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2024-01-15 19:28:00 +02:00
Riku Viitanen 0d49d6fcbe make activity led optional
some boards don't define PICO_DEFAULT_LED_PIN, so compiling would fail.
let's make led commands conditional on that being defined.

some boards have ws2812 addressable rgb leds, which could be supported
in the future, if someone wanted to implement it.

Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-12-23 14:58:51 +02:00
Riku Viitanen f0ad99bdfa increase gpio drive strength
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-11-29 23:39:58 +02:00
Riku Viitanen 74f937f863 minor refactoring
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-11-29 17:11:55 +02:00
Riku Viitanen 4f25565a3d add metadata for picotool
For now, set a description and link to the code, plus pin definitions:
$ picotool info -bp *.uf2
File pico_serprog.uf2:

Program Information
 name:         pico_serprog
 web site:     https://codeberg.org/Riku_V/pico-serprog/
 description:  SPI flash chip programmer using Flashrom's serprog protocol

Fixed Pin Information
 2:   SCK
 3:   MOSI
 4:   MISO
 5:   CS
 25:  Activity LED

Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-11-28 21:26:36 +02:00
Riku Viitanen 0f4b78a83d light led when processing a command
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-11-28 20:32:42 +02:00
Riku Viitanen f9be0c789c Add udev rule to create /dev/serprog0, 1, 2, ...
Just copy it into /etc/udev/rules.d/
2023-09-05 19:53:33 +03:00
Riku Viitanen 36bc681dc2 Include board name in product string 2023-09-04 22:03:35 +03:00
Riku Viitanen 030bfdfa94 Make USB descriptor less generic
iManufacturer=libreboot.org
iProduct=pico-serprog
iInterface=serprog
iSerial=64-bit ID, unique to each board (actually flash chip)

Since VID and PID are unchanged, functionality stays the same. This makes
it easier to identify the programmer, whether manually or in udev rules.

lsusb output:
Bus 002 Device 025: ID cafe:4001 libreboot.org pico-serprog

dmesg output:
usb 2-1.2: new full-speed USB device number 25 using ehci-pci
usb 2-1.2: New USB device found, idVendor=cafe, idProduct=4001, bcdDevice= 1.00
usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.2: Product: pico-serprog
usb 2-1.2: Manufacturer: libreboot.org
usb 2-1.2: SerialNumber: E661A4D417788C29
cdc_acm 2-1.2:1.0: ttyACM0: USB ACM device

Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-04 21:33:59 +03:00
Riku Viitanen c8c16e9c11 Add CC-BY-SA 4.0 International license
Source: https://creativecommons.org/licenses/by-sa/4.0/legalcode.txt
2023-09-01 05:34:27 +03:00
Riku Viitanen 51a50ac9db Add pinout.png
Based on pico-pinout.svg by Raspberry Pi Ltd, released under the
Creative Commons Attribution-ShareAlike 4.0 International license.

https://www.raspberrypi.com/documentation/microcontrollers/images/pico-pinout.svg
https://creativecommons.org/licenses/by-sa/4.0/

Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-01 05:28:07 +03:00
Riku Viitanen 300a2517e6 Document performance
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-08-28 00:22:13 +03:00
Riku Viitanen 4c2a7b54cd More beginner-friendly documentation
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-08-27 23:53:45 +03:00
Mate Kukri 14d004ca02 Use TinyUSB directly instead of the SDK's stdio layer 2021-08-07 02:42:16 +01:00
Mate Kukri fe27a2d185 Use hardware SPI peripheral (WARN: this changed pinout!) 2021-08-07 01:34:05 +01:00
Mate Kukri 57e5f20c2f Improve performance 2021-08-07 00:04:38 +01:00
Thomas Roth 09f8d67fca Update readme 2021-04-03 18:38:35 +02:00
Thomas Roth b5d9c3a720 Init 2021-04-03 18:36:40 +02:00