[Tinyos-help] Bugs found in Deluge/TOSBoot

ZHANG Mingze zhangmi3 at comp.nus.edu.sg
Mon Dec 25 22:28:25 PST 2006


Hi,

This is an update. The bugs have been confirmed and identified.

The precompiled main.ihex in tinyos1.15 is compiled from tinyos1.14 code. 
The code in 1.14 works for mica2, but not mica2dot, the problem is in 
mica2dot/hardware.h void TOSH_SET_PIN_DIRECTIONS(void) function.

The function should be
  void TOSH_SET_PIN_DIRECTIONS(void)
  {
   outp(0x00, DDRA);
   outp(0x00, DDRB);
   outp(0x00, DDRC);
   outp(0x00, DDRD);
   outp(0x02, DDRE);
   outp(0x02, PORTE);
   TOSH_SET_RED_LED_PIN();
   TOSH_MAKE_RED_LED_OUTPUT();

   TOSH_MAKE_PW7_OUTPUT();
   TOSH_MAKE_PW6_OUTPUT();
   TOSH_MAKE_PW5_OUTPUT();
   TOSH_MAKE_PW4_OUTPUT();
   TOSH_MAKE_PW3_OUTPUT();
   TOSH_MAKE_PW2_OUTPUT();
   TOSH_MAKE_PW1_OUTPUT();
   TOSH_MAKE_PW0_OUTPUT();

   TOSH_MAKE_FLASH_CS_OUTPUT();
   TOSH_MAKE_FLASH_OUT_OUTPUT();
   TOSH_MAKE_FLASH_CLK_OUTPUT();
   TOSH_SET_FLASH_CS_PIN();
  }

The original function in 1.14 is
void TOSH_SET_PIN_DIRECTIONS(void)
{
   outp(0x00, DDRA);
   outp(0x00, DDRB);
   outp(0x00, DDRC);
   outp(0x00, DDRD);
   outp(0x02, DDRE);
   outp(0x02, PORTE);
}

TOSBoot in 1.15 is not working at all, there are two bugs, one is what I 
mentioned in previous mail,
    if (initAddr == TOSBOOT_END)
this check should be deleted.

Another one is related to chaning of type from uint32_t to 
in_flash_addr_t, which causes ProgramFlash program confusion when program 
the words, which may incorrectly programs the code in wrong byte order. I 
didn't check where the error is but this is the almost only big changes 
from 1.14 to 1.15 in TOSBoot.

Rgds,
Mingze

On Sun, 24 Dec 2006, ZHANG Mingze wrote:

> Hi all,
>
> I was debugging Deluge on mica2dot for two days and finally found something 
> wrong in Deluge/TOSBoot, hope anyone who has knowledge on this can confirm 
> with me.
>
> First, the Deluge/TOSBoot/build/mica2/main.ihex shipped in 1.1.15 rpm (both 
> tinyos and linux) is alright, but Deluge/TOSBoot/build/mica2dot/main.ihex 
> does not work.
>
> Second, the Deluge/TOSBoot/TOSBootM.nc is not working for both mica2 & 
> mica2dot (I am curious where the mica2/main.ihex comes from if this code is 
> not working). I further debug into, and find this line is not working for 
> mica2 and mica2dot,
>            if (intAddr != TOSBOOT_END)
>                  return ERROR;
>
> the TOSBOOT_END is not defined anywhere for both mica2 and mica2dot. Actually 
> the initial address of both mica2 and mica2dot is 0x0000,
> (I can confirm this in the binary image written on External Flash, I have 
> read them out and read line by line, the intial address is 0x0000. This image 
> on External Flash is right because mica2/main.ihex shipped with the rpm is 
> able to reprogram the image without any problem),
> so here the program should be,
>
>            if (intAddr != 0x0000)
>                  return ERROR;
>
> Then, the problem is still not solved, I use LED count to count that there 
> are exactly 90 loops in the real programming code, each loop 256bytes of 
> binary will be reprogrammed (except the last loop), the section length is 
> 22982 for the BlinkDeluge application, 22982/256 is exactly 89.77 so I 
> believe all codes from flash are correctly written to Program Flash. However, 
> although the reprogramming succeeds, the reprogrammed program is not correct 
> (for example for the BlinkApplication, the LED is not blinking after 
> reprogram).
>
> So I wonder where's anything else can be wrong in TOSBootM.nc. The thing I 
> suspect is ProgramFlash.nc but I am not sure. Hope anyone can help out.
>
> Really thanks for the patients to read through, and hope my findings can help 
> somebody else who is also struggling here..
>
> Anyway, is it possible that the Deluge team is able to provide me with the 
> correct bootloader main.ihex for mica2dot too? If so, it will save  me a lot 
> of time.
>
> Regards,
> Mingze
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at Millennium.Berkeley.EDU
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>


More information about the Tinyos-help mailing list