This is good. I don't think I've heard anyone officially using flash yet.
Can you tell us how fast it is to boot from flash if you already know or can test it easily, e.g. time from the rising edge of reset to start of small app booting from flash to toggle a pin? I am still waiting to hear if it is slow or fast, and if fast, just how fast.
Be good to know how fast for the smallest app to boot, as well as an app that takes up the full amount of memory space (~512k), then we will know if it makes sense for some two stage booter in order to shave off time, assuming it runs from RC clock initially but could be switched to faster XTAL frequency early.
I'll try and get some figures asap.
The ROM booter detects the flash and loads 1024 bytes (my loader) into hub.
If the checksum = 'Prop' then the code starts.
My loader then loads the code from flash to hub and then starts it.
Looks like this could be automated with a little change...
Leave off the code that determines "size" and the size long and the objs and then compile.
Then, you append this binary with one long of the obj size and then the obj binary.
Right?
Could one of you please do an experiment where a deterministic program boots from flash and simply reports a GETRND value? Just want to be sure that it is unique on every boot/reset.
Could one of you please do an experiment where a deterministic program boots from flash and simply reports a GETRND value? Just want to be sure that it is unique on every boot/reset.
Chip
I ran some test code and here's the results of 8 power cycles reading GETRND.
I've got a problem re-flashing though. I have to temporarily make P59 pull-up to get an update to take. This stops the existing repeated resets occurring while still having the flash connected. Presumably the fast cycling auto-reset is interfering with the USB reset sequence.
I can't test this. First, I set the "Flash" and P95DN switches. Then I load the program using Spin 2 GUI. However, if any of those switches is set, I get a message that it can't find a P2. That, plus the inability to boot from the SD, makes me think that my board is not working correctly.
I can't test this. First, I set the "Flash" and P95DN switches. Then I load the program using Spin 2 GUI. However, if any of those switches is set, I get a message that it can't find a P2. That, plus the inability to boot from the SD, makes me think that my board is not working correctly.
Kind regards, Samuel Lourenço
I don't know about the timing of Spin2 GUI, but if you set the flash switch on with the others off, you should be able to download from PNut.
Samuel, it's possible there could be something wrong with your board. We tested every pin on the chip, but we didn't test the flash or the SD socket. If there is anything wrong, it ought to be apparent by visual inspection. Look at the flash and SD card SMT components through a magnifier and see if everything looks okay.
Personally, I had many problems with solder bridges that stay hidden under capacitors and resistors (0805s), when soldering with solder paste and hot air. I'll do an inspection tomorrow and some measurements as well, to see if the switches are having an effect. A simple test I could do is to measure P59 with both of its switches on. If the switches are OK, I should measure around 1.65V there.
By the way, I should mention that I can read the contents of the SD card under TAQOZ (although, I only tried the DIR command). On another note, where can I get PNut?
I can't test this. First, I set the "Flash" and P95DN switches. Then I load the program using Spin 2 GUI. However, if any of those switches is set, I get a message that it can't find a P2. That, plus the inability to boot from the SD, makes me think that my board is not working correctly.
The FLASH switch is needed on for all flash ops. Try turning on P59 Up. I can make it program with both P59 Up and Down on together.
Sorry
I program the flash with both P59 switches off and 'FLASH' on.
After programming I set P69 pulldown on for fast SPI boot.
For all my testing I use Pnut.
I just love GETNIB/SETNIB and their ALTxx prefixes!
...
Thanks for the tip. I may be able to use it in the ROM Monitor for the next silicon
evan
Here is your code (untested) using...
1. Hopefully a standard method to set the xtal frequency. (note I didn't decode your divide/multiply/divide to get 180MHz)
2. Using the Serial ROM Monitor to display your results.
'' RR20190119 001 mod to use the monitor serial routines
CON
_XTALFREQ = 20_000_000 ' crystal frequency
_XDIV = 4 '\ '\ crystal divider to give 5.0MHz
_XMUL = 72 '| 180MHz '| crystal / div * mul to give 360MHz
_XDIVP = 2 '/ '/ crystal / div * mul /divp to give 180MHz
_XOSC = %10 '15pF ' %00=OFF, %01=OSC, %10=15pF, %11=30pF
_XSEL = %11 'XI+PLL ' %00=rcfast(20+MHz), %01=rcslow(~20KHz), %10=XI(5ms), %11=XI+PLL(10ms)
_XPPPP = ((_XDIVP>>1) + 15) & $F ' 1->15, 2->0, 4->1, 6->2...30->14
_CLOCKFREQ = _XTALFREQ / _XDIV * _XMUL / _XDIVP ' internal clock frequency
_SETFREQ = 1<<24 + (_XDIV-1)<<18 + (_XMUL-1)<<8 + _XPPPP<<4 + _XOSC<<2 ' %0000_000e_dddddd_mmmmmmmmmm_pppp_cc_00 ' setup oscillator
_ENAFREQ = _SETFREQ + _XSEL ' %0000_000e_dddddd_mmmmmmmmmm_pppp_cc_ss ' enable oscillator
'------------------------------------------------------------------------------------------------
_baud = 115_200
_bitper = (_clockfreq / _baud) << 16 + 7 ' 115200 baud, 8 bits
_txmode = %0000_0000_000_0000000000000_01_11110_0 'async tx mode, output enabled for smart output
_rxmode = %0000_0000_000_0000000000000_00_11111_0 'async rx mode, input enabled for smart input
'------------------------------------------------------------------------------------------------
rx_pin = 63 ' pin serial receiver
tx_pin = 62 ' pin serial transmitter
'------------------------------------------------------------------------------------------------
''============[ ROM MONITOR Equates]=============================================================
_HUBBUF = $FC000 ' overwrite Booter (used as serial receive buffer, etc)
_SerialInit = $fcab8 ' Serial Initialise (lmm_x & lmm_bufad must be set first)
_HubTxCR = $fcae4 ' Sends <cr><lf> (overwrites lmm_x)
_HubTx = $fcaf0 ' Sends lmm_x (can be up to 4 bytes)
_HubHex8 = $fcb28 ' Sends lmm_x as Hex char(s) after setting lmm_f as 8 hex chars
''-------[ COG LMM parameters, etc ]-------------------------------------------------------------
lmm_x = $1e0 ' parameter passed to/from LMM routine (typically a value)
''-----------------------------------------------------------------------------------------------
value = lmm_x
DAT
orgh $400
org
stage1
getrnd value1
getrnd value2
getrnd value3
getrnd value4
'+-------[ Set Xtal ]----------------------------------------------------------+
'' hubset ##clk | %1111_10_00 'enable crystal+PLL, stay in 20MHz+ mode
'' waitx ##20_000_000/100 'wait ~10ms for crystal+PLL to stabilize
'' hubset ##clk | %1111_10_11 'now switch to PLL running at 180 MHz
hubset #0 ' set 20MHz+ mode
hubset ##_SETFREQ ' setup oscillator
waitx ##20_000_000/100 ' ~10ms
hubset ##_ENAFREQ ' enable oscillator
'+-----------------------------------------------------------------------------+
'+-------[ Start Serial ]------------------------------------------------------+
'' wrpin #%1_11110_0,#tx_pin
'' wxpin ##nco | 7,#tx_pin
'' dirh #tx_pin
mov lmm_bufad, ##_HUBBUF ' locn of hub buffer for serial routine
mov lmm_x, ##_bitper ' sets serial baud
call #_SerialInit ' initialise serial
'+-----------------------------------------------------------------------------+
'+-------[ Send Serial ]-------------------------------------------------------+
mov value,value1
call #send_hex8 'show result
mov value,value2
call #send_hex8
mov value,value3
call #send_hex8
mov value,value4
call #send_hex8
'' call #newline
call #_hubTxCR
waitx ##sys_clk / 100 'allow time for tx to complete
hubset ##%0001<<28 'hard reset
jmp #$
'+-----------------------------------------------------------------------------+
{{
newline mov pa,#13
call #send_char
mov pa,#10
send_char rdpin pb,#tx_pin wc
if_c jmp #send_char
wypin pa,#tx_pin
ret wcz
send_hex8 mov countx,#8
.loop getnib pa,value,#7
cmp pa,#9 wcz
if_a add pa,#"A"-10
if_be add pa,#"0"
call #send_char
rol value,#4
djnz countx,#.loop
space mov pa,#" "
jmp #send_char
}}
send_hex8 call #_hubHex8
mov lmm_x,#" "
call #_hubTx
ret
'+-----------------------------------------------------------------------------+
''value res 1 'use lmm_x
value1 res 1
value2 res 1
value3 res 1
value4 res 1
''countx res 1
There are a couple of other tricks that I will put up on the Tricks and Traps thread...
' convert nibble to ASCII hex char using only the C flag
getnib x,value,#7 '\ either extracts only lower nibble
and x,#$0F '/
or x,#"0"
cmp x,#";" wc ' : -> A etc
if_nc add x,#7
' convert nibble to ASCII hex char using only the C flag
getnib x,value,#7 '\ either extracts only lower nibble
and x,#$0F '/
or x,#"0"
cmp x,#";" wc ' : -> A etc
if_nc add x,#7
The AND after the GETNIB is not required.
Also the #";" should be #":"
' convert nibble to ASCII hex char using only the C flag
getnib x,value,#7 '\ either extracts only lower nibble
or x,#"0"
cmp x,#":" wc ' : -> A etc
if_nc add x,#7
I can't test this. First, I set the "Flash" and P95DN switches. Then I load the program using Spin 2 GUI. However, if any of those switches is set, I get a message that it can't find a P2. That, plus the inability to boot from the SD, makes me think that my board is not working correctly.
The FLASH switch is needed on for all flash ops. Try turning on P59 Up. I can make it program with both P59 Up and Down on together.
Thanks evanh! That worked while programming with Spin 2 GUI. I get the program loaded up and apparently running. P56 blinks, although it doesn't show anything on the terminal yet.
Sorry
I program the flash with both P59 switches off and 'FLASH' on.
After programming I set P69 pulldown on for fast SPI boot.
For all my testing I use Pnut.
Try turning on P59 Up. I can make it program with both P59 Up and Down on together.
Thanks evanh! That worked while programming with Spin 2 GUI. I get the program loaded up and apparently running. P56 blinks, although it doesn't show anything on the terminal yet.
Next step is turn P59 Up off again and press the reset button.
Try turning on P59 Up. I can make it program with both P59 Up and Down on together.
Thanks evanh! That worked while programming with Spin 2 GUI. I get the program loaded up and apparently running. P56 blinks, although it doesn't show anything on the terminal yet.
Next step is turn P59 Up off again and press the reset button.
Strange, after pressing reset, with P59 Up already in the off position, P56 blinks no more. If I set P59 Down off, leaving FLASH on, and then reset again, I can't load TAQOZ. This should mean that the program is loaded from the flash, but not showing information on the terminal. This also happens if I turn P59 Down on again.
Comments
This is good. I don't think I've heard anyone officially using flash yet.
Can you tell us how fast it is to boot from flash if you already know or can test it easily, e.g. time from the rising edge of reset to start of small app booting from flash to toggle a pin? I am still waiting to hear if it is slow or fast, and if fast, just how fast.
Roger.
The ROM booter detects the flash and loads 1024 bytes (my loader) into hub.
If the checksum = 'Prop' then the code starts.
My loader then loads the code from flash to hub and then starts it.
It is a little endian format value.
From the docs
I think he was referring to the typo in the comment: 'Proo' instead of 'Prop'
Code is good to go!
I'm way to focused on the PASM I didn't even notice the typo in the comment.
Apologies @pmrobert
Leave off the code that determines "size" and the size long and the objs and then compile.
Then, you append this binary with one long of the obj size and then the obj binary.
Right?
Chip
I ran some test code and here's the results of 8 power cycles reading GETRND. and here's the result og 8 resets.
Looks Ok.
Leave the terminal running, move the WAIT to after send so tx finishes, and add a HUBSET reset to make it repeat indefinitely ...
And data dump attached
It looks okay, doesn't it?
First glance looks great. Probably should do some binning or something ... that's actual work.
I can't test this. First, I set the "Flash" and P95DN switches. Then I load the program using Spin 2 GUI. However, if any of those switches is set, I get a message that it can't find a P2. That, plus the inability to boot from the SD, makes me think that my board is not working correctly.
Kind regards, Samuel Lourenço
No, I don't think that would mean anything. The PRNG is running, being what it is, and we just need to know that it started up with a unique value.
I don't know about the timing of Spin2 GUI, but if you set the flash switch on with the others off, you should be able to download from PNut.
Samuel, it's possible there could be something wrong with your board. We tested every pin on the chip, but we didn't test the flash or the SD socket. If there is anything wrong, it ought to be apparent by visual inspection. Look at the flash and SD card SMT components through a magnifier and see if everything looks okay.
Personally, I had many problems with solder bridges that stay hidden under capacitors and resistors (0805s), when soldering with solder paste and hot air. I'll do an inspection tomorrow and some measurements as well, to see if the switches are having an effect. A simple test I could do is to measure P59 with both of its switches on. If the switches are OK, I should measure around 1.65V there.
By the way, I should mention that I can read the contents of the SD card under TAQOZ (although, I only tried the DIR command). On another note, where can I get PNut?
Kind regards, Samuel Lourenço
The FLASH switch is needed on for all flash ops. Try turning on P59 Up. I can make it program with both P59 Up and Down on together.
I program the flash with both P59 switches off and 'FLASH' on.
After programming I set P69 pulldown on for fast SPI boot.
For all my testing I use Pnut.
Thanks for the tip. I may be able to use it in the ROM Monitor for the next silicon
evan
Here is your code (untested) using...
1. Hopefully a standard method to set the xtal frequency. (note I didn't decode your divide/multiply/divide to get 180MHz)
2. Using the Serial ROM Monitor to display your results.
There are a couple of other tricks that I will put up on the Tricks and Traps thread...
The AND after the GETNIB is not required.
Also the #";" should be #":"
[/quote]
As for the AND, it’s an either GETNIB or AND, not both.
I've tested the switches, and they appear to work correctly. The measured voltages make sense.
Thanks evanh! That worked while programming with Spin 2 GUI. I get the program loaded up and apparently running. P56 blinks, although it doesn't show anything on the terminal yet.
Thanks! That worked well with PNut.
Kind regards, Samuel Lourenço
What could be the issue here?
Kind regards, Samuel Lourenço