Commit 7ebf3a37 authored by Prashant Patil's avatar Prashant Patil

rearranged files

parent 004d53a7
Pipeline #998 passed with stage
in 5 seconds
File added
*.o
*.d
*.elf
*.hex
*.eep
*.sym
*.bin
*.lss
*.map
*.bak
*.class
Documentation/
LUFA/StudioIntegration/ProjectGenerator/*
LUFA/StudioIntegration/DocBook/*
!LUFA/StudioIntegration/Docbook/mshelp/*
*.lss
*.bin
*.elf
*.hex
*.eep
*.map
*.o
*.d
*.sym
/*
DMBS Build System
Released into the public domain.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/** \file
*
* Special application to extract an EEPROM image stored in FLASH memory, and
* copy it to the device EEPROM. This application is designed to be used with
* the HID build system module of DMBS to program the EEPROM of a target device
* that uses the HID bootloader protocol, which does not have native EEPROM
* programming support.
*/
#include <avr/io.h>
#include <avr/eeprom.h>
#include <avr/pgmspace.h>
/* References to the binary EEPROM data linked in the AVR's FLASH memory space */
extern const char _binary_InputEEData_bin_start[];
extern const char _binary_InputEEData_bin_end[];
extern const char _binary_InputEEData_bin_size[];
/* Friendly names for the embedded binary data stored in FLASH memory space */
#define InputEEData _binary_InputEEData_bin_start
#define InputEEData_size ((int)_binary_InputEEData_bin_size)
int main(void)
{
/* Copy out the embedded EEPROM data from FLASH to EEPROM memory space */
for (uint16_t i = 0; i < InputEEData_size; i++)
eeprom_update_byte((uint8_t*)i, pgm_read_byte(&InputEEData[i]));
/* Infinite loop once complete */
for (;;);
}
#
# DMBS Build System
# Released into the public domain.
#
# dean [at] fourwalledcubicle [dot] com
# www.fourwalledcubicle.com
#
# Run "make help" for target help.
MCU = atmega128
ARCH = AVR8
F_CPU = 1000000
OPTIMIZATION = s
TARGET = HID_EEPROM_Loader
SRC = $(TARGET).c
CC_FLAGS =
LD_FLAGS =
OBJECT_FILES = InputEEData.o
# Default target
all:
# Determine the AVR sub-architecture of the build main application object file
FIND_AVR_SUBARCH = avr$(shell avr-objdump -f $(TARGET).o | grep architecture | cut -d':' -f3 | cut -d',' -f1)
# Create a linkable object file with the input binary EEPROM data stored in the FLASH section
InputEEData.o: InputEEData.bin $(TARGET).o $(MAKEFILE_LIST)
@echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a object file \"$@\"
avr-objcopy -I binary -O elf32-avr -B $(call FIND_AVR_SUBARCH) --rename-section .data=.progmem.data,contents,alloc,readonly,data $< $@
# Include LUFA build script makefiles
include ../core.mk
include ../gcc.mk
include ../hid.mk
DMBS Build System
Released into the public domain.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
DMBS - Dean's Makefile Build System
===================================
Modules Overview
----------------
The following modules are currently included:
- [ATPROGRAM](atprogram.md) - Device Programming
- [AVRDUDE](avrdude.md) - Device Programming
- [CORE](core.md) - DMBS Core Functionality
- [CPPCHECK](cppcheck.md) - Static Code Analysis
- [DFU](dfu.md) - Device Programming
- [DOXYGEN](doxygen.md) - Automated Source Code Documentation
- [GCC](gcc.md) - Compiling/Assembling/Linking with GCC
- [HID](hid.md) - Device Programming
## Importing modules into your project makefile
To use a module, it is recommended to add the following boilerplate to your
makefile:
# Include DMBS build script makefiles
DMBS_PATH ?= ../DMBS
Which can then used to indicate the location of your DMBS installation, relative
to the current directory, when importing modules. For example:
DMBS_PATH ?= ../DMBS
include $(DMBS_PATH)/core.mk
include $(DMBS_PATH)/gcc.mk
Imports the `CORE` and `GCC` modules from DMBS using a single path relative to
your project's makefile.
If you wish to write your own DMBS module(s),
[see the documentation here for more details.](WritingYourOwnModules.md)
DMBS - Dean's Makefile Build System
===================================
Writing Your Own Modules
------------------------
A DMBS module consists of the several boilerplate sections, explained below.
## The DMBS module hooks
Your module needs to advertise to DMBS its name, its makefile targets, the
required and optional variables, and the variables and macros the module
provides for use elsewhere. This is achieved with the following section:
DMBS_BUILD_MODULES += EXAMPLE
DMBS_BUILD_TARGETS += example-target another-target
DMBS_BUILD_MANDATORY_VARS += MANDATORY_NAME ALSO_MANDATORY
DMBS_BUILD_OPTIONAL_VARS += OPTIONAL_NAME ALSO_OPTIONAL
DMBS_BUILD_PROVIDED_VARS += MEANING_OF_LIFE
DMBS_BUILD_PROVIDED_MACROS += STRIP_WHITESPACE
The example above declares that this module is called `EXAMPLE`, and exposes the
listed targets, variable requirements and provides variables and macros.
Your module name and provided variable/macro names must be unique, however you
can (and should) re-use variable names where appropriate if they apply to
several modules (such as `ARCH` to specify the project's microcontroller
architecture). Re-using targets is not recommended, but can be used to extend
the dependencies of another module's targets.
## Importing the CORE module
Next, your module should always import the DMBS `CORE` module, via the
following:
# Conditionally import the CORE module of DMBS if it is not already imported
DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),)
include $(DMBS_MODULE_PATH)/core.mk
endif
This ensures that the `make help` target is always available. In addition, the
`CORE` module exposes some [commonly used macros and variables](core.md) to
your module.
## Setting optional variable's defaults
If a variable is optional, you should provide a default value. Do this via the
`?=` operator of `make`, which sets a variable's value if it has not yet been
set:
MY_OPTIONAL_VARIABLE ?= some_default_value
## Sanity checking user input
Sanity checks are what make DMBS useful. Where possible, validate user input and
convert generated errors to human-friendly messages. This can be achieved by
enforcing that all the declared module mandatory variables have been set by the
user:
# Sanity-check values of mandatory user-supplied variables
$(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
As well as complaining if they are set, but currently empty:
$(call ERROR_IF_EMPTY, SOME_MANDATORY_VARIABLE)
$(call ERROR_IF_EMPTY, SOME_OPTIONAL_BUT_NON_EMPTY_VARIABLE)
Or even if they are boolean (`Y` or `N`) variables that have an invalid value:
$(call ERROR_IF_NONBOOL, SOME_BOOL_VARIABLE)
## Adding targets
The meat of a DMBS module is the targets, which are run when the user types
`make {target name}` from the command line. These can be as complex or simple
as you like. See the GNU make manual for information on writing make targets.
example-target:
echo "Your DMBS module works!"
## And finally, list the PHONYs
Important in GNU Make is the concept of phony targets; this special directive
tells make that a given target should never be considered a valid file. Listing
phonies ensures that, for example, if your module had a target called `build`,
it would always run when the user types `make build` from the command line, even
if a file called `build` existed in the user project folder.
You can list module-internal targets here, as well as mark all public targets
via the module header's `DMBS_BUILD_TARGETS` variable.
# Phony build targets for this module
.PHONY: $(DMBS_BUILD_TARGETS) some-module-internal-target another-internal-target
DMBS - Dean's Makefile Build System
===================================
Module: ATPROGRAM
-----------------
The ATPROGRAM module provides build targets for use with the official
`ATPROGRAM` back-end utility distributed with the free
[Atmel Studio](http://www.atmel.com) software released by Atmel.
## Importing This Module into a Makefile:
To use this module in your application makefile, add the following code to your
makefile:
include $(DMBS_PATH)/atprogram.mk
## Prerequisites:
This module requires the `atprogram.exe` utility to be available in your
system's `PATH` variable. The `atprogram.exe` utility is distributed in Atmel
Studio (usually) inside the application install folder's `atbackend`
subdirectory.
## Build Targets:
The following targets are supported by this module:
<table>
<tbody>
<tr>
<td>atprogram</td>
<td>Program the device FLASH memory with the application's executable data.</td>
</tr>
<tr>
<td>atprogram-ee</td>
<td>Program the device EEPROM memory with the application's EEPROM data.</td>
</tr>
</tbody>
</table>
## Mandatory Variables:
The following variables must be defined (with a `NAME = VALUE` syntax, one
variable per line) in the user makefile to be able to use this module:
<table>
<tbody>
<tr>
<td>MCU</td>
<td>Name of the Atmel processor model (e.g. `at90usb1287`).</td>
</tr>
<tr>
<td>TARGET</td>
<td>Name of the application output file prefix (e.g. `TestApplication`).</td>
</tr>
</tbody>
</table>
## Optional Variables:
The following variables may be defined (with a `NAME = VALUE` syntax, one
variable per line) in the user makefile. If not specified, a default value will
be assumed.
<table>
<tbody>
<tr>
<td>ATPROGRAM_PROGRAMMER</td>
<td>Name of the Atmel programmer or debugger tool to communicate with (e.g. `jtagice3`). Default is `atmelice`.</td>
</tr>
<tr>
<td>ATPROGRAM_INTERFACE</td>
<td>Name of the programming interface to use when programming the target (e.g. `spi`). Default is `jtag`.</td>
</tr>
<tr>
<td>ATPROGRAM_PORT</td>
<td>Name of the communication port to use when when programming with a serially connected tool (e.g. `COM2`). Default is `usb`.</td>
</tr>
</tbody>
</table>
## Provided Variables:
The following variables may be referenced in a user makefile (via `$(NAME)`
syntax) if desired, as they are provided by this module.
<table>
<tbody>
<tr>
<td>N/A</td>
<td>This module provides no variables.</td>
</tr>
</tbody>
</table>
## Provided Macros:
The following macros may be referenced in a user makefile (via
`$(call NAME, ARG1, ARG2, ...)` syntax) if desired, as they are provided by
this module.
<table>
<tbody>
<tr>
<td>N/A</td>
<td>This module provides no macros.</td>
</tr>
</tbody>
</table>
## Module Changelog:
The changes to this module since its initial release are listed below, as of the
DMBS version where the change was made.
### 20160403
Initial release.
#
# DMBS Build System
# Released into the public domain.
#
# dean [at] fourwalledcubicle [dot] com
# www.fourwalledcubicle.com
#
DMBS_BUILD_MODULES += ATPROGRAM
DMBS_BUILD_TARGETS += atprogram atprogram-ee
DMBS_BUILD_MANDATORY_VARS += MCU TARGET
DMBS_BUILD_OPTIONAL_VARS += ATPROGRAM_PROGRAMMER ATPROGRAM_INTERFACE ATPROGRAM_PORT
DMBS_BUILD_PROVIDED_VARS +=
DMBS_BUILD_PROVIDED_MACROS +=
# Conditionally import the CORE module of DMBS if it is not already imported
DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),)
include $(DMBS_MODULE_PATH)/core.mk
endif
# Default values of optionally user-supplied variables
ATPROGRAM_PROGRAMMER ?= atmelice
ATPROGRAM_INTERFACE ?= jtag
ATPROGRAM_PORT ?=
# Sanity check user supplied values
$(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
$(call ERROR_IF_EMPTY, MCU)
$(call ERROR_IF_EMPTY, TARGET)
$(call ERROR_IF_EMPTY, ATPROGRAM_PROGRAMMER)
$(call ERROR_IF_EMPTY, ATPROGRAM_INTERFACE)
# Output Messages
MSG_ATPROGRAM_CMD := ' [ATPRGRM] :'
# Construct base atprogram command flags
BASE_ATPROGRAM_FLAGS := --tool $(ATPROGRAM_PROGRAMMER) --interface $(ATPROGRAM_INTERFACE) --device $(MCU)
ifneq ($(ATPROGRAM_PORT),)
BASE_ATPROGRAM_FLAGS += --port $(ATPROGRAM_PORT)
endif
# Construct the flags to use for the various memory spaces
ifeq ($(ARCH), AVR8)
ATPROGRAM_FLASH_FLAGS := --chiperase --flash
ATPROGRAM_EEPROM_FLAGS := --eeprom
else ifeq ($(ARCH), XMEGA)
ATPROGRAM_FLASH_FLAGS := --erase --flash
ATPROGRAM_EEPROM_FLAGS := --eeprom
else ifeq ($(ARCH), UC3)
ATPROGRAM_FLASH_FLAGS := --erase
ATPROGRAM_EEPROM_FLAGS := --eeprom
else
$(error Unsupported architecture "$(ARCH)")
endif