Commit Graph

133 Commits

Author SHA1 Message Date
Sean Cross
f88a76c3b0 sw: dfu: use macro for SPI flash offset
Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-20 21:29:58 +08:00
Sean Cross
ae0df08489 sw: usb-desc: update landing URL and product name
Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-20 21:29:29 +08:00
Sean Cross
3ad9853278 sw: usb-desc: mark product name as "static const"
Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-20 21:28:40 +08:00
Sean Cross
4050898b51 sw: use foosn as the manufacturer
Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-20 12:33:07 +08:00
Sean Cross
b708810f00 sw: dfu: fix sentinal search on null first packet
When the first packet is NULL, we weren't searching for the sentinal
properly.  Limit the amount of data we search for.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-20 12:29:42 +08:00
Sean Cross
a3f1ee6d44 sw: fix typo in main
Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-20 11:22:18 +08:00
Sean Cross
c5b5397529 initial commit of foboot main
This is an initial commit of a non-recovery version of foboot.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-20 10:59:48 +08:00
Sean Cross
c89bb50ebc dfu: reset timeout to a sane value
Somehow it defaults to something that is very unreasonable.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-14 19:26:12 +08:00
Sean Cross
8f5de3fb62 sw: usb-epfifo: remove dead code and fix usb behavior
This fixes USB behavior so it's much more reliable.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-12 21:48:03 +08:00
Sean Cross
2adac57076 sw: epfifo: use new fifo arrangement
Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-10 23:41:18 +08:00
Sean Cross
e7493017a0 sw: initial commit of boot options
This adds the ability to configure the program that will be loaded.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-01 14:08:30 -07:00
Sean Cross
9c7db8a84a sw: usb-desc: fix usb version
It should be 2.1, not 2.10.  This fixes Windows enumeration.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-05-01 08:59:42 -07:00
Sean Cross
5d6a0d0ec7 sw: webusb: fix landing descriptor warning
For some reason, -flto didn't like the "extern const struct" definition.
Hide the variable now and use an accessor function to silence this
warning, which may have caused other issues with stability.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-26 09:22:11 +08:00
Sean Cross
b8145bde36 sw: use correct abi
The CPU we're using has no div/mul instructions, so use the rv32i ABI
instead of rv32im.

This saves about 15%.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-25 13:29:27 +08:00
Sean Cross
cd6151b009 sw: add -flto to cflags
This reduces codesize by 15% (~1 kB).

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-25 12:07:13 +08:00
Sean Cross
646388fcb7 sw: dfu: fix calculation for address offset
We were using the wrong offset for address calculation.  Use the block
size, rather than the program size.  This wasn't an issue before, because
the block size and the program size were both 256 bytes.  Now the block
size can be 1024 bytes.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-22 15:51:57 +08:00
Sean Cross
b3050ae299 sw: spi: comment out dead code
This code emitted a warning.  It's not used, so leave it commented for now.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-22 15:08:49 +08:00
Sean Cross
b8151d46a4 sw: ld: limit bootloader to 4096 bytes
It doesn't need any more, and we can use the rest of RAM to load a
temporary program.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-22 14:49:20 +08:00
Sean Cross
6e653b98d6 sw: support loading directly to RAM
If a sentinal is present, allow dfu-util to load a program directly to
RAM.  This saves us the step of writing to flash.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-22 14:42:14 +08:00
Sean Cross
85bb787536 sw: support 1024-byte DFU writes
This increases performance of DFU write commands.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-22 14:19:09 +08:00
Sean Cross
26a327486f sw: minor shrink of sw code size
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-22 12:03:01 +08:00
Sean Cross
8faf9dbec5 sw: remove printf
There is no UART in the failsafe bootloader, so remove printf.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-22 11:42:44 +08:00
Sean Cross
f36dde5c7e swp: remove swapfile
This got added somehow.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-22 11:20:09 +08:00
Sean Cross
c0690187b4 Merge branch 'wishbone-debug' 2019-04-21 21:48:33 +08:00
Sean Cross
eb6fa89452 merge debug
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-21 21:48:16 +08:00
Sean Cross
91a205fe2c Merge branch 'master' of github.com:im-tomu/foboot into wishbone-debug
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-18 21:35:20 +08:00
Sean Cross
e7184d9243 no changes
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-18 21:34:39 +08:00
Sean Cross
bfd1ddc957 sw: update csr definition for bios
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-11 15:57:36 +08:00
Sean Cross
e5a2b29456 sw: fix line endings
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-11 15:53:08 +08:00
Sean Cross
9144b767a8 sw: fix line endings
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-11 11:48:57 +08:00
Sean Cross
482708d6fb sw: spi: remove broken, unused Write command
The Write command was from fomu-flash, and didn't properly erase the
required sectors.  This wasn't an issue, because it is entirely unused.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-11 11:47:10 +08:00
Sean Cross
9cb4e4a8ce WIP: riscv boot
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-11 09:40:28 +08:00
Sean Cross
0bcc45b185 sw: update to use picospi
Use the new picospi instead of bbspi.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-10 17:02:02 +08:00
Sean Cross
d89eea3934 usb: refactor state machine to work with xhci devices
Due to some subtle quirks, as well as a poorly-implemented state machine,
foboot was not compatible with many Desktop devices.

This should fix the implementation so that it is more compatible.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-08 17:19:54 +08:00
Sean Cross
595be29063 sw: Makefile: use 32-bit riscv compiler on rpi
The rpi image does not have a 64-bit riscv compiler.  Use the
32-bit version of the toolchain if we detect we're on an rpi.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-07 04:55:13 +01:00
Sean Cross
4b6ad47705 sw: spi-gpio: remove unused files
These were moved into spi.c to allow them to be inlined.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-06 11:04:43 +08:00
Sean Cross
91a23d808c sw: Makefile: fix third_party and package naming
With these changes, litex mode should now work.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-06 10:51:08 +08:00
Sean Cross
a9a5f0cc0d sw: minor removal of unused code
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-06 09:35:50 +08:00
Sean Cross
d6ae51f69b sw: ld: add support for litex build
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-06 09:35:23 +08:00
Sean Cross
2437e8b5c1 sw: Makefile: support litex build environment
Allow this software package to be built from within the Litex build system.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-06 09:34:26 +08:00
Sean Cross
b40a9bad43 rgb: fix typo in macro
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-05 18:17:11 +08:00
Sean Cross
b5f17acdf6 sw: enable fancy led effects
Support different LED patterns depending on the mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-05 18:10:05 +08:00
Sean Cross
fd76536351 usb-dev: reboot to image 0
Since this is a failsafe bootloader, reboot to Image 0.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-05 17:33:28 +08:00
Sean Cross
eaa0d63ccb usb-epfifo: fix DATA0/DATA1 swaps for Tx
We were sometimes sending DATA0 instead of DATA1.  Fix that.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-05 17:33:02 +08:00
Sean Cross
7d091a72b9 main: poll dfu in main loop
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-05 15:10:19 +08:00
Sean Cross
7bcc8529d6 dfu: initial working commit
This commit actually works, but still has a few issues.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-05 15:09:52 +08:00
Sean Cross
ac349ce1a1 spi: support 32- and 64-kB erase blocks
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-05 15:09:04 +08:00
Sean Cross
cbf4958236 usb-epfifo: remove extra USB_NAK setting
This works around an issue, though it's still not properly working.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-05 13:21:09 +08:00
Sean Cross
2b0575889f usb-dev: remove commented-out printf statements
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-05 13:20:54 +08:00
Sean Cross
c92af747cd spi: actually transmit data
We were sending data on CS, not on CLK.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-05 13:19:46 +08:00
Sean Cross
d72925fdeb sw: experimental improved dfu performance
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-03 22:11:31 +08:00
Sean Cross
85b6d75882 sw: update to latest generated files
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-02 18:11:25 +08:00
Sean Cross
dbc0f81715 usb: re-enable extra usb descriptors
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-02 18:11:09 +08:00
Sean Cross
851e54e70c main: initialize rgb driver
Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-02 18:10:56 +08:00
Sean Cross
85bdc7991c rgb: add initial rgb code
It initializes the rgb driver, and can write to its registers.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-02 18:10:17 +08:00
Sean Cross
a3c05bd19e sw: system: add reset key to reboot()
Add the key `0xac` to the reset command, to prevent accidental resets.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-02 16:40:09 +08:00
Sean Cross
33aec0876b sw: usb-epfifo: disable usb events before disconnect
If we don't disconnect the usb event system, then we will lock up
in an irq storm.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-02 16:39:13 +08:00
Sean Cross
0a4c73a63a sw: wip commit -- dfu state machine works, spi broken
Need to fix SPI and SB_WARMBOOT, but the DFU state machine now works.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-28 11:13:25 +08:00
Sean Cross
a3298226e5 sw: getting dfu working about to add debug bridge
We're having issues getteing DFU working.  It almost works, but has some
issues.  Unfortunately, we're out of space for printf.

Now we will work to get the UART Wishbone bridge working, to move
forward on debugging support.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-26 09:39:55 +08:00
Sean Cross
b0afd2b0ae sw: puts: don't eat first character
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-25 18:59:57 +08:00
Sean Cross
3d6acaf51e sw: wip commit -- getting dfu working
Now that we have SPI and USB both working, we can start to close the
loop and get DFU working.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-25 17:39:06 +08:00
Sean Cross
7210ee219d sw: add div/mul instructions
For foboot, we're using a CPU without a divide or multiply instruction,
to save gates.  Replace these with software implementations.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-21 11:01:46 +08:00
Sean Cross
2139317530 sw: include: sync csr.h and mem.h
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-20 13:14:57 +08:00
Sean Cross
dd9cdfa7a3 sw: usb-epfifo: make buffer pointers static
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-20 13:14:20 +08:00
Sean Cross
03327067ff sw: add spi base
This is taken from fomu-flash, and needs to be adapted.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-20 11:23:19 +08:00
Sean Cross
ff4774ebc3 sw: usb-epfifo: fixups to remove errors in enumeration
With these fixups, we can now enumerate successfully.

The code is a mess, but this is the first functionally-correct build.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-11 11:51:19 +08:00
Sean Cross
9909b3bbdb sw: usb-desc: set product name to "Fomu Bootloader"
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-11 11:50:55 +08:00
Sean Cross
f5fd282d61 sw: usb-dev: remove errant i++
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-10 22:46:02 +08:00
Sean Cross
d64f88d995 sw: usb-epfifo: mostly-working commit
Still has issues with large reads.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-10 22:42:14 +08:00
Sean Cross
c180c1b1b8 sw: usb-epfifo: increase packet size to 64 bytes
This masks some problems we're seeing.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-10 22:41:22 +08:00
Sean Cross
a552d1eb91 usb-dev: limit the size of outgoing packets
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-10 22:40:52 +08:00
Sean Cross
69f7b5d836 csr: replace with latest generated version
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-10 20:53:30 +08:00
Sean Cross
c98017cbc9 client: working on the client
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-10 15:25:33 +08:00
Sean Cross
3df59a866d metastable fix: wip
Trying to figure out what's causing this problem.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-05 20:28:54 +08:00
Sean Cross
c0842737bf sw: usb-unififo: add code to test usb RX
This just reads SOF packets and validates they're correct.  This ensures
that bitstuffing is good.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-05 15:50:36 +08:00
Sean Cross
ce071dac67 sw: main: remove usb_sync() call
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-05 15:50:08 +08:00
Sean Cross
7f30d7f79b sw: Makefile: hardcode project name to "foboot"
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-05 15:49:21 +08:00
Sean Cross
380a4f1fa2 sw: unififo: print out SOF frames, to ensure link integrity
Print out the SOF frames so that we can make sure the Rx path is good.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-05 14:52:42 +08:00
Sean Cross
c78e9ab214 sw: add missing include files
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-05 12:02:02 +08:00
Sean Cross
ffd0285613 main: more work on fixing stuff
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-05 11:54:48 +08:00
Sean Cross
1c38c58a6f Merge branch 'master' of git.xobs.io:xobs/foboot 2019-03-05 09:18:20 +08:00
Sean Cross
e4af98b4aa generated: update generated csr, mem, and ld files
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-05 09:05:29 +08:00
Sean Cross
84d4b40897 foboot: move software stuff to sw directory
Signed-off-by: Sean Cross <sean@xobs.io>
2019-03-05 08:54:51 +08:00