
Dear Pantelis,
in message 3E9E9B5C.30904@intracom.gr you wrote:
The following patch against u-boot-0.3.0 adds support for booting ARTOS images using u-boot. ARTOS is a custom in-house operating system in use by my company.
I will not add the patch for now, as it contains some severe problems:
- /*
* Booting an ARTOS kernel image + application
*/
- /* place data at the top of memory */
- top = gd->bd->bi_memstart + gd->bd->bi_memsize;
- /* first check the artos specific boot args, then the linux args*/
- if ((s = getenv("abootargs")) == NULL && (s = getenv("bootargs")) == NULL)
s = "";
- /* get length of cmdline, and place it */
- len = strlen(s);
- top = (top - (len + 1)) & ~0xF;
- cmdline = (char *)top;
- debug ("## cmdline at 0x%08lX ", top);
- strcpy(cmdline, s);
^^^^^^^^^^^^^^^^^^^^^^^^^^^
- /* copy bdinfo */
- top = (top - sizeof(bd_t)) & ~0xF;
- debug ("## bd at 0x%08lX ", top);
- kbd = (bd_t *)top;
- memcpy(kbd, gd->bd, sizeof(bd_t));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You cannot do that. U-Boot copies itself to the top of memory, so you are overwriting U-Boot's data here. It was pure luck if this wrked for you. but the behaviour is completely undefined.
Please implement this in a way that is compatible to U-Boot's memory map.
Also, since this is a proprietary OS with a very limited propagation I would like to ask to make the ARTOS boot code configurable, i. e. add a #define so it can enabled it in the board config file, but will not add to the code size for those systems that don't want it.
Best regards,
Wolfgang Denk