Fix Quail nanoBooter main code
Reworked code to comply with latest workflow.
#include <hal.h>
#include <cmsis_os.h>
-#include <usbcfg.h>
+#include <targetHAL.h>
#include <WireProtocol_ReceiverThread.h>
#include <LaunchCLR.h>
@@ -53,15 +53,15 @@ int main(void) {
osKernelInitialize();
// Initializes a serial-over-USB CDC driver.
- sduObjectInit(&SDU1);
- sduStart(&SDU1, &serusbcfg);
+ //sduObjectInit(&SDU1);
+ //sduStart(&SDU1, &serusbcfg);
// Activates the USB driver and then the USB bus pull-up on D+.
// Note, a delay is inserted in order to not have to disconnect the cable after a reset.
- usbDisconnectBus(serusbcfg.usbp);
- chThdSleepMilliseconds(1500);
- usbStart(serusbcfg.usbp, &usbcfg);
- usbConnectBus(serusbcfg.usbp);
+ //usbDisconnectBus(serusbcfg.usbp);
+ //chThdSleepMilliseconds(1500);
+ //usbStart(serusbcfg.usbp, &usbcfg);
+ //usbConnectBus(serusbcfg.usbp);
// Creates the blinker thread, it does not start immediately.
blinkerThreadId = osThreadCreate(osThread(BlinkerThread), NULL);
@@ -81,9 +81,14 @@ int main(void) {
osThreadTerminate(blinkerThreadId);
// stop the serial-over-USB CDC driver
- sduStop(&SDU1);
+ //sduStop(&SDU1);
+ // check for valid CLR image at address contiguous to nanoBooter
+ if(CheckValidCLRImage((uint32_t)&__nanoImage_end__))
+ {
+ // there seems to be a valid CLR image
// launch nanoCLR
- LaunchCLR(0x08008000);
+ LaunchCLR((uint32_t)&__nanoImage_end__);
+ }
}
