reboot from a python program

Firmware/software/electronics
Post Reply
ellesse
Beginner
Posts: 11
Joined: Thu Mar 26, 2015 10:35 am

reboot from a python program

Post by ellesse »

Can you reboot crazyflie 2.0 from a python program (i.e without using the main switch)?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: reboot from a python program

Post by arnaud »

Yes you can. By sending "magic packets" you can reboot to bootloader or to firmware. This was intended as a bootloader hot-boot but we do not have it stable yet.

To restart to firmware:

Code: Select all

from crazyradio import Crazyradio

cr = Crazyradio()

cr.set_channel(100)
cr.set_data_rate(cr.DR_2MPS)

print cr.send_packet((0xff, 0xfe, 0xff)).ack   # Init the reboot
# print cr.send_packet((0xff, 0xfe, 0xf0, 0)).ack   # Reboot to Bootloader
print cr.send_packet((0xff, 0xfe, 0xf0, 1)).ack   # Reboot to Firmware
One trick is that when rebooting to bootloader that way, the bootloader will take another radio address. This address is send back when the reboot-init packet is sent to the copter.
ellesse
Beginner
Posts: 11
Joined: Thu Mar 26, 2015 10:35 am

Re: reboot from a python program

Post by ellesse »

Thanks.
sstroobants
Beginner
Posts: 20
Joined: Wed Jan 30, 2019 1:13 pm

Re: reboot from a python program

Post by sstroobants »

Hi, very late reply to this old message:
My on/off button broke and I tried resetting it to bootloader using this method and it seems to work (blue lights showing). I just cannot update the firmware, since (I guess because you said this in your previous response) the address has changed. As you said, the address should be sent back with the first message. But I am not quite sure how to get this new address. Will this be in the data property? This property returns ['B', 243]. Let me know if you can help me!
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: reboot from a python program

Post by arnaud »

The bootloader command line sofware has a mode to handle the address change. It is done using the -w flag, if you are developing with the Crazyflie firmware you can add this line in your config.mk: https://github.com/bitcraze/crazyflie-f ... xample#L48

If you want to flash a release zip you can use the same flag in the console: "python3 -m cfloader -w radio://0/100/2M/E7E7E7E7E7 flash release_zip.zip".
sstroobants
Beginner
Posts: 20
Joined: Wed Jan 30, 2019 1:13 pm

Re: reboot from a python program

Post by sstroobants »

Thanks! I totally forgot about the cfloader... Only tried it with make cfload. Now I get the same problem as in this thread however: viewtopic.php?t=3837&p=17662. But I'll post a reply there.

EDIT: Just pulled the latest version of both the crazyflie-clients-python and crazyflie-lib-python and reinstalled them and now it works.
Post Reply