<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/4395" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2010-06-10T18:48:52+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/4395</id>

		<entry>
		<author><name><![CDATA[frank26080115]]></name></author>
		<updated>2010-06-10T18:48:52+02:00</updated>

		<published>2010-06-10T18:48:52+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14740#p14740</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14740#p14740"/>
		<title type="html"><![CDATA[Re: possible to jump between bootloader and the main program?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14740#p14740"><![CDATA[
Hmm... I don't think this is practical. The problem is probably due to memory (what variables is saved where).<br /><br />If the generated HEX file is identical for both the application code and bootloader code (obviously with a offset in the flash address), then your bootloader can probably just skip usbInit and it &quot;should&quot; work. But this is not the case, it's just not possible with the circumstances you described.<br /><br />The only way you can do this is to either make sure the variable somehow stay in the same place or a known location (a dedicated chunk in the stack maybe?) and have the bootloader read that location when it detects a jump.<br /><br />If you were to just push and pop the V-USB variables into/from the stack, GCC might reset stack pointer during initialization, if it doesn't (find out if it does) then you can probably push and pop all of the static V-USB variables when jumping.<br /><br />If that doesn't work, maybe you can be ballsy and allocate a block on the heap in your application code, and have the bootloader code find it. Basically make the application malloc and save a string in memory like &quot;0000QWERTY&quot; (note, you need to pad a few bytes before the letter &quot;Q&quot; depending on the static memory allocation differences between the bootloader code and the application code) followed by an array of bytes representing the V-USB static variables, and have the bootloader scan from null to where the letter Q starts, try and match the next &quot;WERTY&quot; (if no match, find next &quot;Q&quot;), if a match is found, then load the V-USB static variables with the array of bytes found after &quot;QWERTY&quot;. This is an extremely stupid way of doing this though.<br /><br />You can also try saving and loading the variables to/from eeprom, or external memory of some kind.<br /><br />No guarantee that any of this will work, you are welcome to try for fun though.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=2426">frank26080115</a> — Thu Jun 10, 2010 6:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2010-06-10T12:58:03+02:00</updated>

		<published>2010-06-10T12:58:03+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14738#p14738</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14738#p14738"/>
		<title type="html"><![CDATA[Re: possible to jump between bootloader and the main program?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14738#p14738"><![CDATA[
thank you frank,<br />but this is not the main problem,  the main problem is<br />that after entering the mainprogram the device does not recognize.<br />if bootloadercondition is not valid, my atmega168 enters the mainprogramm,<br />goes throw the initForUsbConnectivity(void) ---&gt; disconnect -&gt; reconnect<br />and it works...<br />I tried to modify initForUsbConnectivity(void) ... to take disconnect away, so<br />that the pc-side don't realize any changes... the result is, that something goes<br />wrong. I still see the device in windows, but my application can't get it...<br />I have to remove/modify something in my usbinit function... but I don't know where the problem could be.<p>Statistics: Posted by Guest — Thu Jun 10, 2010 12:58 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[frank26080115]]></name></author>
		<updated>2010-06-09T23:44:50+02:00</updated>

		<published>2010-06-09T23:44:50+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14730#p14730</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14730#p14730"/>
		<title type="html"><![CDATA[Re: possible to jump between bootloader and the main program?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14730#p14730"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>typedef void (*AppPtr_t)(void) __attribute__ ((noreturn)); <br /><br />AppPtr_t AppStartPtr = (AppPtr_t)0x0000; <br />AppStartPtr();</code></pre></div><br /><br />That's code I found here<br /><!-- m --><a class="postlink" href="http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=viewtopic&amp;p=493336">http://www.avrfreaks.net/index.php?name ... c&amp;p=493336</a><!-- m --><br /><br />So modify it with the bootloader address instead.<br /><br /><div class="codebox"><p>Code: </p><pre><code>typedef void (*AppPtr_t)(void) __attribute__ ((noreturn)); <br /><br />AppPtr_t BootloaderPtr = (AppPtr_t)0xAddressGoesHere; <br />BootloaderPtr();</code></pre></div><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=2426">frank26080115</a> — Wed Jun 09, 2010 11:44 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2010-06-08T13:51:47+02:00</updated>

		<published>2010-06-08T13:51:47+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14713#p14713</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14713#p14713"/>
		<title type="html"><![CDATA[possible to jump between bootloader and the main program?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4395&amp;p=14713#p14713"><![CDATA[
Hello guys  <img class="smilies" src="./../../../images/smilies/icon_razz.gif" alt=":P" title="Razz" /> <br />nice forum, with a lot of problems...<br />thanks in advance for reading this topic<br /><br />I run bootloadHID and I love it. In the main program i have the same code and<br />I want to switch between the main programm and the bootloader without reenumeration...<br />disconnect &gt; reconnect... and so on.<br />Is this intention possible? Or do I break a lot of usb-rules by jumping out to the main program...<br />I tried to modify initForUsbConnectivity in main.c... but without a positive response  <img class="smilies" src="./../../../images/smilies/icon_sad.gif" alt=":(" title="Sad" /><p>Statistics: Posted by Guest — Tue Jun 08, 2010 1:51 pm</p><hr />
]]></content>
	</entry>
	</feed>
