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

Doesn't seem to be running after flash #12

Open
Applepi opened this issue Nov 20, 2019 · 8 comments
Open

Doesn't seem to be running after flash #12

Applepi opened this issue Nov 20, 2019 · 8 comments

Comments

@Applepi
Copy link

Applepi commented Nov 20, 2019

When using a CP2102 with an upduino after flashing it doesn't appear to be doing anything, no leds are blinking or anything I'm not sure what I'm doing wrong, I've tried flashing a few versions but so far no dice. I've tried setting to different pins and such but none seem to respond.

@grahamedgecombe
Copy link
Owner

Are you using the UPDuino v1 or v2?

Can you paste the exact make commands (including variables) that you used to build/flash?

Do you see anything on the serial port? The default example program will output 'hello, world' once a second at 9600 baud 8N1.

I don't have an UPDuino to test on, the support for it was contributed by someone else. I'll double check the current master branch on my iCEBreaker when I get home though, as that does use the same FPGA.

@Applepi
Copy link
Author

Applepi commented Nov 20, 2019

I'm using an upduino v2.0

Picom is using this: sudo picocom -b 9600 /dev/ttyUSB1

Building with

export PATH=/opt/riscv32i/bin/:$PATH
make BOARD=upduino

riscv32-unknown-elf-gcc -v [7:42:58] Using built-in specs. COLLECT_GCC=riscv32-unknown-elf-gcc COLLECT_LTO_WRAPPER=/opt/riscv32i/libexec/gcc/riscv32-unknown-elf/8.2.0/lto-wrapper Target: riscv32-unknown-elf Configured with: /home/nota/ice/riscv-gnu-toolchain-rv32i/build/../riscv-gcc/configure --target=riscv32-unknown-elf --prefix=/opt/riscv32i --disable-shared --disable-threads --enable-languages=c,c++ --with-system-zlib --enable-tls --with-newlib --with-sysroot=/opt/riscv32i/riscv32-unknown-elf --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --src=../../riscv-gcc --enable-checking=yes --disable-multilib --with-abi=ilp32 --with-arch=rv32i 'CFLAGS_FOR_TARGET=-Os -mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-Os -mcmodel=medlow' Thread model: single gcc version 8.2.0 (GCC)

The following output results:

nota•~/ice/icicle(master)» make BOARD=upduino                                                                                                                                                                                                                                                                                                        [7:45:40]
nextpnr-ice40 -q --up5k --package sg48 --json top.json --pcf boards/upduino.pcf --freq 16 --asc top_syn.asc
cp top_syn.asc top.asc
icepack -s top.asc top.bin
nota•~/ice/icicle(master)» sudo make BOARD=upduino flash                                                                                                                                                                                                                                                                                             [7:46:41]
Password:
icetime -t -m -d up5k -P sg48 -p boards/upduino.pcf -c 16 -r top.rpt top_syn.asc
// Reading input .pcf file..
// Reading input .asc file..
// Reading 5k chipdb file..
// Creating timing netlist..
Warning: timing analysis not supported for cell type HFOSC
// Timing estimate: 43.05 ns (23.23 MHz)
// Checking 62.50 ns (16.00 MHz) clock constraint: PASSED.
iceprog top.bin
init..
cdone: high
reset..
cdone: high
flash ID: 0xEF 0x40 0x16 0x00
file size: 104090
erase 64kB sector at 0x000000..
erase 64kB sector at 0x010000..
programming..
reading..
VERIFY OK
cdone: high
Bye.
iceprog -o 1M progmem.bin
init..
cdone: high
reset..
cdone: high
flash ID: 0xEF 0x40 0x16 0x00
file size: 192
erase 64kB sector at 0x100000..
programming..
reading..
VERIFY OK
cdone: high
Bye.

Green LED comes on to say that it's flashed but nothing on serial and no other leds are blinking or any sign on life.

This is the output of the serial

picocom v3.1

port is        : /dev/ttyUSB1
flowcontrol    : none
baudrate is    : 9600
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        :
omap is        :
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready


Thanks for your help.

@grahamedgecombe
Copy link
Owner

Not completely sure about this, but I think the upduino board config in icicle is for an upduino v1. I don't know if the v1 pinout is compatible with v2. I'll investigate further tonight.

@tomverbeure
Copy link
Contributor

If you’re referring to the Upduino patches that I pushed last year: that’s for a v2.0.

Tom

@grahamedgecombe
Copy link
Owner

grahamedgecombe commented Nov 20, 2019

Looking at the PCF file and comparing it to the pinout/PCF here: https://github.com/osresearch/up5k#schematics-and-pinout https://github.com/osresearch/up5k/blob/master/upduino_v2.pcf I think it won't work out of the box with the serial or on-board RGB LED.

uart_rx/tx are currently set to pin 12 and 21, which are GPIOs, so by default the serial port will only work with an external FTDI cable and not the on-board FTDI chip.

I think the serial could be adjusted to work with the on-board FTDI chip, but as it uses the same FTDI channel as the SPI flash you'd need to:

  • Remove the SPI_FLASH define from boards/upduino-defines.sv.
  • Set PROGMEM to ram in boards/upduino.mk.
  • Change the uart_{rx,tx} pins to 14 and 15 in boards/upduino.pcf (or maybe the other way round, haven't checked!)
  • Ensure that pin 16 is always high so the flash chip isn't selected. Should be fairly easy to do by tweaking the Verilog - I'd re-add the output logic flash_csn port to the icicle module and add assign flash_csn = 1 to the body.

As for the LEDs, it looks like those are also currently all configured to use GPIOs. You could try hooking some of your own LEDs up to those pins or testing the pins with a multimeter.

Alternatively, as it looks like the upduino has an on-board RGB LED, you could try changing some of the LED pins to the R, G and B pins (39, 40 and 41) in the .pcf file. I'm not sure if those will work with SB_IO or whether you'd also need to add code to use SB_RGBA_DRV.

@Applepi
Copy link
Author

Applepi commented Nov 21, 2019

Yep switching to RAM, using the internal UART and setting CS to high allowed me to get UART outputting, but I'm not sure why it wouldn't work when using the SPI flash? I had the CP2102 connected to the pins listed in the board definition file previously but when I hooked it up to the oscilloscope I was just getting clock jitter.

@grahamedgecombe
Copy link
Owner

hmm, it'd be interesting to know if it works with the CP2102 but without the SPI flash enabled, as that'd narrow the cause down to definitely being the SPI flash.

@s-ol
Copy link

s-ol commented Oct 14, 2021

I'm a bit late to the party but this might help others with an Upduino v2.0. I tested using a logic analyzer and external serial cable on pins 12/21; as mentioned above, the onboard FTDI and USB are slightly harder to use, if only because the USB port doesn't always show up on Linux until the port is re-plugged for me.

With the configuration currently in the tree I can't get it to boot properly. The RX/TX lines remain high and the led pins are stuck at 0b00000001 as far as I can tell. However by setting PROGMEM = ram and commenting the SPI_FLASH define, it works fine:

diff --git a/boards/upduino-defines.sv b/boards/upduino-defines.sv
index 18d8f5a..6252120 100644
--- a/boards/upduino-defines.sv
+++ b/boards/upduino-defines.sv
@@ -1,3 +1,3 @@
 // Defines for Upduino
-`define SPI_FLASH
+// `define SPI_FLASH
 `define INTERNAL_OSC
diff --git a/boards/upduino.mk b/boards/upduino.mk
index 57f784c..17c40fb 100644
--- a/boards/upduino.mk
+++ b/boards/upduino.mk
@@ -3,4 +3,4 @@ SPEED    = up
 DEVICE   = 5k
 PACKAGE  = sg48
 FREQ_OSC = 48
-PROGMEM  = flash
+PROGMEM  = ram

For reference, I build and flash with make TARGET=/opt/riscv/bin/riscv64-unknown-elf BOARD=upduino flash and applied this patch at commit c653af1. I also figured out after a bit of messing around that make clean is required after messing around with upduino.mk.

I'm not quite sure what is up with the flash, but I also don't know enough about what and how it is even used here to debug it; if there is any info I can help provide with little experiments let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants