mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 06:42:32 +08:00
Add support for the Atollic Pro toolchain; Change extension .ihx to .hex to be better compatible with most of the rest of the world
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4431 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -199,41 +199,36 @@ Loading NuttX with PICkit2
|
||||
directory:
|
||||
|
||||
1) nuttx - This is an ELF file, and
|
||||
2) nuttx.ihx - This is an Intel Hex format file. This is controlled by
|
||||
2) nuttx.hex - This is an Intel Hex format file. This is controlled by
|
||||
the setting CONFIG_INTELHEX_BINARY in the .config file.
|
||||
|
||||
The PICkit tool wants an Intel Hex format file to burn into FLASH.
|
||||
However, there are two problems with the generated nutt.ihx:
|
||||
|
||||
1) The tool expects Intel Hex format files to be named *.hex. This
|
||||
is not a significant issue. However, just renaming the file to
|
||||
nuttx.hex is *not* sufficient. There is another problem:
|
||||
2) The tool expects the nuttx.hex file to contain physical addresses.
|
||||
But the nuttx.ihx file generated from the top-level make will have
|
||||
address in the KSEG0 and KSEG1 regions.
|
||||
The PICkit tool wants an Intel Hex format file to burn into FLASH. However,
|
||||
there is a problem with the generated nutt.hex: The tool expects the nuttx.hex
|
||||
file to contain physical addresses. But the nuttx.hex file generated from the
|
||||
top-level make will have address in the KSEG0 and KSEG1 regions.
|
||||
|
||||
tools/mkpichex:
|
||||
---------------
|
||||
|
||||
There is a simple tool in the configs/sure-pic32mx/tools directory
|
||||
that can be used to solve both issues with the nuttx.ihx file. But,
|
||||
that can be used to solve both issues with the nuttx.hex file. But,
|
||||
first, you must build the the tools:
|
||||
|
||||
cd configs/sure-pic32mx/tools
|
||||
make
|
||||
|
||||
Now you will have an excecutable file call mkpichex (or mkpichex.exe on
|
||||
Cygwin). This program will take the nutt.ihx file as an input, it will
|
||||
Cygwin). This program will take the nutt.hex file as an input, it will
|
||||
convert all of the KSEG0 and KSEG1 addresses to physical address, and
|
||||
it will write the modified file as nuttx.hex.
|
||||
it will write the modified file, replacing the original nuttx.hex.
|
||||
|
||||
To use this file, you need to do the following things:
|
||||
|
||||
. ./setenv.sh # Source setenv.sh. Among other this, this script
|
||||
# will add configs/sure-pic32mx/tools to your
|
||||
# PATH variable
|
||||
make # Build nuttx and nuttx.ihx
|
||||
mkpichex $PWD # Convert nuttx.ihx to nuttx.hex. $PWD is the path
|
||||
make # Build nuttx and nuttx.hex
|
||||
mkpichex $PWD # Convert addresses in nuttx.hex. $PWD is the path
|
||||
# to the top-level build directory. It is the only
|
||||
# required input to mkpichex.
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
############################################################################
|
||||
# configs/sure-pic32mx/tools/Makefile
|
||||
#
|
||||
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
@@ -41,7 +41,7 @@ default: mkpichex
|
||||
|
||||
CFLAGS = -O2 -Wall -I.
|
||||
|
||||
# mkpichex - Convert nuttx.ihx to nuttx.hex
|
||||
# mkpichex - Convert virtual addresses in nuttx.hex to physical addresses
|
||||
|
||||
mkconfig: mkpichex.c mkpichex.c
|
||||
@gcc $(CFLAGS) -o mkpichex mkpichex.c
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/****************************************************************************
|
||||
* configs/sure-pic32mx/tools/mkpichex.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -125,7 +125,7 @@ static inline char *getfilepath(const char *path, const char *name, const char *
|
||||
|
||||
static void show_usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s <abs path to nuttx.ihx>\n", progname);
|
||||
fprintf(stderr, "USAGE: %s <abs path to nuttx.hex>\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -246,14 +246,14 @@ int main(int argc, char **argv, char **envp)
|
||||
show_usage(argv[0]);
|
||||
}
|
||||
|
||||
srcfile = getfilepath(argv[1], "nuttx", "ihx");
|
||||
srcfile = getfilepath(argv[1], "nuttx", "hex");
|
||||
if (!srcfile)
|
||||
{
|
||||
fprintf(stderr, "getfilepath failed\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
destfile = getfilepath(argv[1], "nuttx", "hex");
|
||||
destfile = getfilepath(argv[1], "nuttx", "tmp");
|
||||
if (!destfile)
|
||||
{
|
||||
fprintf(stderr, "getfilepath failed\n");
|
||||
@@ -295,5 +295,21 @@ int main(int argc, char **argv, char **envp)
|
||||
|
||||
fclose(src);
|
||||
fclose(dest);
|
||||
|
||||
/* Remove the original nuttx.hex file */
|
||||
|
||||
if (remove(srcfile) != OK)
|
||||
{
|
||||
fprintf(stderr, "Failed to remove the old '%s'\n", srcfile);
|
||||
|
||||
}
|
||||
|
||||
/* Rename the new nuttx.tmp file to nuttx.hex */
|
||||
|
||||
if (rename(destfile, srcfile) != OK)
|
||||
{
|
||||
fprintf(stderr, "Failed to rename '%s' to '%s'\n", destfile, srcfile);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user