Reboot/Soft Reset possible?

Technical questions regarding the XTC tools and programming with XMOS.
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post by DemoniacMilk »

Sorry for bringing up such an old topic, but I would really like to have a possibility for a software reset.

I tried to have my system reset using the posted function, but it seemed to not work, so I wrote a small application (LED Port for eXplorerKit):

Code: Select all

#include <xs1.h>
#include <platform.h>

out port    leds = on tile[0]: XS1_PORT_4F;

void chipReset(void)
{
  unsigned x;
  leds <: 0x8;  // red LED on
  delay_ticks(100000000);   // wait
  // write to PLL for reset
  read_sswitch_reg(get_local_tile_id(), 6, x);
  write_sswitch_reg(get_local_tile_id(), 6, x);
}

int main() {
    unsigned delay = 10;

    leds <: 0x7;
    delay_ticks(100000000);
    leds <: 0x0;
    delay_ticks(100000000);

    while (1){
        leds <: 0x7;
        delay_ticks(10000000);
        leds <: 0x0;
        delay_ticks(10000000);
        delay--;

        if (!delay)
            chipReset();
    }
    return 0;
}
The program was flashed onto an explorerKit before execution.

Expected behavior on success:
  1. 1 slow on/off blink (all LEDs but Red)
  2. 10 fast on/off blinks (all LEDs but Red)
  3. Red LED turned on
  4. reset / repeat
Expected behavior on fail:
  1. 1 slow on/off blink (all LEDs but Red)
  2. 10 fast on/off blinks (all LEDs but Red)
  3. Red LED turned on
  4. eternal fast on/off blinks (all LEDs but Red)
With the code provided, latter is the case.

I searched for a register map on the XE216 devices (to check what register number 6 actually is - maybe i just have to adjust the number) but couldnt find any.


henk
Respected Member
Posts: 347
Joined: Wed Jan 27, 2016 5:21 pm

Post by henk »

Hi,
I searched for a register map on the XE216 devices (to check what register number 6 actually is - maybe i just have to adjust the number) but couldnt find any.
The data sheet - appendices A-F (depending on whether you need USB or not)
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post by DemoniacMilk »

Ah the data sheet even states:

D.5 PLL settings: 0x06
An on-chip PLL multiplies the input clock up to a higher frequency clock, used to
clock the I/O, processor, and switch, see Oscillator. Note: a write to this register
will cause the tile to be reset.


It only resets the tile, not the entire system.

Is there a way to force a global system reset?
henk
Respected Member
Posts: 347
Joined: Wed Jan 27, 2016 5:21 pm

Post by henk »

Ha! You spotted an error in the data sheet. It will reset the node, not just the tile, so this is the register that should do the trick.

I've been scratching my head why your code wouldn't work. All calls are to old style functions (you would use something like write_node_config_reg(tile[0], 6, x) with the recent tools); but that shouldn't be an issue.
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post by DemoniacMilk »

hm, any thoughts or ideas on what might go wrong and how the device might be reset then?
malo
Active Member
Posts: 33
Joined: Fri Sep 16, 2016 9:03 pm
Contact:

Post by malo »

@DemoniacMilk

check the value which you are writing back to reg 6 and compare with datasheet for you device.
for example for XEF216-512-TQ128
D.5 PLL settings: 0x06
bit 32: If set to 1, the chip will not be reset

wbr
malo
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post by DemoniacMilk »

Code: Select all

        read_sswitch_reg(get_local_tile_id(), 6, &x);
        printstr("reboot register: 0x"); printhexln(x);
        write_sswitch_reg(get_local_tile_id(), 6, x);
(I tried read/write_node_config_reg() as suggested by henk and the data sheet, but it told me the function declaration was implicit, so I switched back).

the printout of this is
reboot register: 0x7C02
so Bit 31 (do not reset) is not set.
malo
Active Member
Posts: 33
Joined: Fri Sep 16, 2016 9:03 pm
Contact:

Post by malo »

Hello DemoniacMilk

I'm using something like this:

read_node_config_reg (tile , 0x6, data);
write_node_config_reg_no_ack (tile , 0x6, data & 0x7FFFFFFF);

and works for me on XEF216-512-TQ128. In my case write_node_config_reg_no_ack declaration is in xs1.h.

wbr
malo
ahogen
Member++
Posts: 26
Joined: Fri Mar 31, 2017 5:16 pm

Post by ahogen »

Note that lib_tsn (I currently have version 7.0.3) has a nice little helper function which is supposed to reboot the device. I haven't checked, but I have a feeling it's probably related to the AVB firmware upgrade functionality.

Have a look at what XMOS is doing for a soft reboot by going to...

Code: Select all

lib_tsn/src/util/reboot.h
lib_tsn/src/util/reboot.xc
... or check it out on Github here: https://github.com/xmos/lib_tsn/blob/ma ... /reboot.xc

With this you should be able to simply include the "reboot.h" header file and call "device_reboot();" and that's that! Haven't tried it since I don't need this, but it seems pretty straightforward.
mariareese
Newbie
Posts: 1
Joined: Sat Jun 03, 2017 1:30 pm

Post by mariareese »

I was also having the same issues and searching for the solution for 3 days .. helping me out at some points.. thanku folks :D

__Regards__________
Maria
Post Reply