Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #ifndef in generic.h, so we can override without local.mk #17

Closed
0x3333 opened this issue Aug 9, 2019 · 2 comments
Closed

Add #ifndef in generic.h, so we can override without local.mk #17

0x3333 opened this issue Aug 9, 2019 · 2 comments

Comments

@0x3333
Copy link
Contributor

0x3333 commented Aug 9, 2019

Currently, if you want to override, for example, APP_BASE_ADDRESS, you have to create another target, as it is not guarded by #ifndef on generic.h file.

Would be nice if we could guard all config defines by #ifndef so we could run as:

make TARGET=STM32F103 LDSCRIPT='../../some.ld' CFLAGS='-DAPP_BASE_ADDRESS=0x08004000'

Which would relocate the app base without a new target or touching the repo. Helps when you have a board with some specificities that don't need to fork the dapboot repo.

generic/config.h would look like:

/*
 * Copyright (c) 2016, Devan Lai
 *
 * Permission to use, copy, modify, and/or distribute this software
 * for any purpose with or without fee is hereby granted, provided
 * that the above copyright notice and this permission notice
 * appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED

#ifndef APP_BASE_ADDRESS
#define APP_BASE_ADDRESS 0x08002000
#endif
#ifndef FLASH_SIZE_OVERRIDE
#define FLASH_SIZE_OVERRIDE 0x20000
#endif
#ifndef FLASH_PAGE_SIZE
#define FLASH_PAGE_SIZE  1024
#endif
#ifndef DFU_UPLOAD_AVAILABLE
#define DFU_UPLOAD_AVAILABLE 1
#endif
#ifndef DFU_DOWNLOAD_AVAILABLE
#define DFU_DOWNLOAD_AVAILABLE 1
#endif

#ifndef HAVE_LED
#define HAVE_LED 0
#endif

#ifndef HAVE_BUTTON
#define HAVE_BUTTON 0
#endif

#ifndef BUTTON_SAMPLE_DELAY_CYCLES
#define BUTTON_SAMPLE_DELAY_CYCLES 1440000
#endif

#ifndef HAVE_USB_PULLUP_CONTROL
#define HAVE_USB_PULLUP_CONTROL 0
#endif

#endif

If you are OK with it, I'm glad to provide a PR.

@devanlai
Copy link
Owner

devanlai commented Aug 9, 2019

This seems like a good idea - I'm all for it.

@0x3333
Copy link
Contributor Author

0x3333 commented Aug 9, 2019

Great, will check if doesn't affect other parts, and issue a PR. Thanks.

devanlai added a commit that referenced this issue Aug 9, 2019
Fixes issue #17 Guard on all defines in config.h
@devanlai devanlai closed this as completed Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants