mirror of https://github.com/ARMmbed/mbed-os.git
synch targets, exporters and tests
parent
f9a1972384
commit
091fe5c3d0
|
@ -0,0 +1,125 @@
|
|||
#include "test_env.h"
|
||||
|
||||
/******************************************************************************
|
||||
This will test an I2C EEPROM connected to mbed by writing a predefined byte at
|
||||
address 0 and then reading it back and comparing it with the known byte value a
|
||||
number of times. This test was written specifically for reproducing the bug
|
||||
reported here:
|
||||
|
||||
https://mbed.org/forum/bugs-suggestions/topic/4128/
|
||||
|
||||
Test configuration:
|
||||
|
||||
* set 'ntests' to the number of iterations
|
||||
* set 'i2c_speed_hz' to the desired speed of the I2C interface
|
||||
* set 'i2c_delay_us' to the delay that will be inserted between 'write' and
|
||||
'read' I2C operations (https://mbed.org/users/mbed_official/code/mbed/issues/1
|
||||
for more details). '0' disables the delay.
|
||||
* define I2C_EEPROM_VERBOSE to get verbose output
|
||||
|
||||
The test ran with a 24LC256 external EEPROM memory, but any I2C EEPROM memory
|
||||
that uses two byte addresses should work.
|
||||
******************************************************************************/
|
||||
|
||||
// Test configuration block
|
||||
static const int ntests = 10000;
|
||||
static const int i2c_freq_hz = 400000;
|
||||
static const int i2c_delay_us = 0;
|
||||
//#define I2C_EEPROM_VERBOSE
|
||||
// End of test configuration block
|
||||
|
||||
#if defined(TARGET_KL25Z)
|
||||
I2C i2c(PTE0, PTE1);
|
||||
#else
|
||||
I2C i2c(p28, p27);
|
||||
#endif
|
||||
|
||||
#ifdef I2C_EEPROM_VERBOSE
|
||||
#define dprintf printf
|
||||
#else
|
||||
int dprintf(const char* args, ...) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
class TestHelper {
|
||||
public:
|
||||
// Defaults to 'passed'
|
||||
TestHelper() {
|
||||
passed();
|
||||
}
|
||||
|
||||
void passed() {
|
||||
m_result = true;
|
||||
}
|
||||
|
||||
void failed() {
|
||||
m_result = false;
|
||||
}
|
||||
|
||||
~TestHelper() {
|
||||
notify_completion(m_result);
|
||||
}
|
||||
private:
|
||||
bool m_result;
|
||||
};
|
||||
|
||||
int main() {
|
||||
const int addr = 0xA0;
|
||||
const char mark = 0x66;
|
||||
char data[3];
|
||||
int fw = 0, fr = 0, fc = 0;
|
||||
int i2c_stat;
|
||||
TestHelper helper;
|
||||
|
||||
i2c.frequency(i2c_freq_hz);
|
||||
|
||||
// Data write
|
||||
data[0] = data[1] = 0;
|
||||
data[2] = mark;
|
||||
if((i2c_stat = i2c.write(addr, data, 3)) != 0) {
|
||||
dprintf("Unable to write data to EEPROM (i2c_stat = 0x%02X), aborting\r\n", i2c_stat);
|
||||
helper.failed();
|
||||
return 1;
|
||||
}
|
||||
// ACK polling (assumes write will be successful eventually)
|
||||
while(i2c.write(addr, data, 0) != 0);
|
||||
|
||||
// Data read (actual test)
|
||||
for(int i = 0; i < ntests; i ++)
|
||||
{
|
||||
data[0] = data[1] = 0;
|
||||
if((i2c_stat = i2c.write(addr, data, 2, true)) != 0)
|
||||
{
|
||||
dprintf("Test %d failed at write, i2c_stat is 0x%02X\r\n", i, i2c_stat);
|
||||
fw ++;
|
||||
continue;
|
||||
}
|
||||
if(i2c_delay_us != 0)
|
||||
wait_us(i2c_delay_us);
|
||||
if((i2c_stat = i2c.read(addr, data, 1)) != 0)
|
||||
{
|
||||
dprintf("Test %d failed at read, i2c_stat is 0x%02X\r\n", i, i2c_stat);
|
||||
fr ++;
|
||||
continue;
|
||||
}
|
||||
if(data[0] != mark)
|
||||
{
|
||||
dprintf("Test %d failed at data match\r\n", i);
|
||||
fc ++;
|
||||
}
|
||||
}
|
||||
dprintf("Test finished.\r\n");
|
||||
if(fw + fr + fc == 0)
|
||||
dprintf("No failures in %d tests.\r\n", ntests);
|
||||
else
|
||||
{
|
||||
dprintf("Statistics:\r\n");
|
||||
dprintf(" Total tests: %d\r\n", ntests);
|
||||
dprintf(" Failed at write: %d\r\n", fw);
|
||||
dprintf(" Failed at read: %d\r\n", fr);
|
||||
dprintf(" Data mismatch: %d\r\n", fc);
|
||||
dprintf(" Total failures: %d\r\n", fw + fr + fc);
|
||||
helper.failed();
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ from os.path import basename
|
|||
class Uvision4(Exporter):
|
||||
NAME = 'uVision4'
|
||||
TOOLCHAIN = 'ARM'
|
||||
TARGETS = ['LPC1768', 'LPC11U24', 'KL25Z']
|
||||
TARGETS = ['LPC1768', 'LPC11U24', 'KL25Z', 'LPC1347']
|
||||
FILE_TYPES = {
|
||||
'c_sources':'1',
|
||||
'cpp_sources':'8',
|
||||
|
@ -21,7 +21,6 @@ class Uvision4(Exporter):
|
|||
source_files.append({
|
||||
'name': basename(file), 'type': n, 'path': file
|
||||
})
|
||||
|
||||
ctx = {
|
||||
'name': self.program_name,
|
||||
'include_paths': self.resources.inc_dirs,
|
||||
|
@ -33,7 +32,4 @@ class Uvision4(Exporter):
|
|||
|
||||
# Project file
|
||||
self.gen_file('uvision4_%s.uvproj.tmpl' % target, ctx, '%s.uvproj' % self.program_name)
|
||||
|
||||
if (target == 'lpc1768' or target == 'lpc11u24' or target == 'kl25z'):
|
||||
# Add debug option to target the MCB1700
|
||||
self.gen_file('uvision4_%s.uvopt.tmpl' % target, ctx, '%s.uvopt' % self.program_name)
|
||||
self.gen_file('uvision4_%s.uvopt.tmpl' % target, ctx, '%s.uvopt' % self.program_name)
|
||||
|
|
|
@ -344,7 +344,7 @@
|
|||
<uThumb>0</uThumb>
|
||||
<VariousControls>
|
||||
<MiscControls>--gnu</MiscControls>
|
||||
<Define>TARGET_LPC11U24</Define>
|
||||
<Define>TARGET_LPC11U24, NDEBUG, TOOLCHAIN_ARM, __CMSIS_RTOS, __CORTEX_M0</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath> {% for path in include_paths %} {{path}}; {% endfor %} </IncludePath>
|
||||
</VariousControls>
|
||||
|
@ -358,7 +358,7 @@
|
|||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<VariousControls>
|
||||
<MiscControls>--gnu</MiscControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
|
|
|
@ -72,7 +72,7 @@ if __name__ == '__main__':
|
|||
setup_test_user_prj()
|
||||
|
||||
for toolchain, target in [
|
||||
('uvision', 'LPC1768'), ('uvision', 'LPC11U24'), ('uvision', 'KL25Z'),
|
||||
('uvision', 'LPC1768'), ('uvision', 'LPC11U24'), ('uvision', 'KL25Z'), ('uvision', 'LPC1347'),
|
||||
|
||||
('codered', 'LPC1768'),
|
||||
|
||||
|
|
|
@ -12,17 +12,19 @@ from optparse import OptionParser
|
|||
ROOT = abspath(join(dirname(__file__), ".."))
|
||||
sys.path.append(ROOT)
|
||||
|
||||
from workspace_tools.settings import MBED_ORG_PATH, MBED_ORG_USER
|
||||
from workspace_tools.settings import MBED_ORG_PATH, MBED_ORG_USER, BUILD_DIR
|
||||
from workspace_tools.paths import LIB_DIR
|
||||
from workspace_tools.utils import cmd, run_cmd
|
||||
|
||||
|
||||
MBED_URL = "mbed.org"
|
||||
# MBED_URL = "world2.dev.mbed.org"
|
||||
|
||||
MBED_REPO_EXT = (".lib", ".bld")
|
||||
|
||||
# mbed_official code that does have a mirror in the mbed SDK
|
||||
OFFICIAL_CODE = (
|
||||
("mbed-src" , "mbed"),
|
||||
|
||||
("mbed-src" , "mbed"),
|
||||
("mbed-rtos", "rtos"),
|
||||
("mbed-dsp" , "dsp"),
|
||||
("mbed-rpc" , "rpc"),
|
||||
|
@ -35,7 +37,7 @@ OFFICIAL_CODE = (
|
|||
("EthernetInterface", "net/eth/EthernetInterface"),
|
||||
|
||||
("USBDevice", "USBDevice"),
|
||||
("USBHost", "USBHost"),
|
||||
("USBHost" , "USBHost"),
|
||||
)
|
||||
|
||||
|
||||
|
@ -71,7 +73,7 @@ CODE_WITH_DEPENDENCIES = (
|
|||
|
||||
|
||||
class MbedOfficialRepository:
|
||||
URL = "http://mbed.org/users/mbed_official/code/%s/"
|
||||
URL = "http://" + MBED_URL + "/users/mbed_official/code/%s/"
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
@ -123,32 +125,35 @@ def visit_files(path, visit, ignore=None, select=None):
|
|||
visit(join(root, file))
|
||||
|
||||
|
||||
def update_repo(repo_name, sdk_path):
|
||||
repo = MbedOfficialRepository(repo_name)
|
||||
# copy files from mbed SDK to mbed_official repository
|
||||
def visit_mbed_sdk(sdk_file):
|
||||
repo_file = join(repo.path, relpath(sdk_file, sdk_path))
|
||||
|
||||
repo_dir = dirname(repo_file)
|
||||
if not exists(repo_dir):
|
||||
makedirs(repo_dir)
|
||||
|
||||
copyfile(sdk_file, repo_file)
|
||||
visit_files(sdk_path, visit_mbed_sdk, ['.json'])
|
||||
|
||||
# remove repository files that do not exist in the mbed SDK
|
||||
def visit_repo(repo_file):
|
||||
sdk_file = join(sdk_path, relpath(repo_file, repo.path))
|
||||
if not exists(sdk_file):
|
||||
remove(repo_file)
|
||||
print "remove: %s" % repo_file
|
||||
visit_files(repo.path, visit_repo, MBED_REPO_EXT)
|
||||
|
||||
repo.publish()
|
||||
|
||||
|
||||
def update_code(repositories):
|
||||
for repo_name, sdk_dir in repositories:
|
||||
print '\n=== Updating "%s" ===' % repo_name
|
||||
repo = MbedOfficialRepository(repo_name)
|
||||
sdk_path = join(LIB_DIR, sdk_dir)
|
||||
|
||||
# copy files from mbed SDK to mbed_official repository
|
||||
def visit_mbed_sdk(sdk_file):
|
||||
repo_file = join(repo.path, relpath(sdk_file, sdk_path))
|
||||
|
||||
repo_dir = dirname(repo_file)
|
||||
if not exists(repo_dir):
|
||||
makedirs(repo_dir)
|
||||
|
||||
copyfile(sdk_file, repo_file)
|
||||
visit_files(sdk_path, visit_mbed_sdk, ['.json'])
|
||||
|
||||
# remove repository files that do not exist in the mbed SDK
|
||||
def visit_repo(repo_file):
|
||||
sdk_file = join(sdk_path, relpath(repo_file, repo.path))
|
||||
if not exists(sdk_file):
|
||||
remove(repo_file)
|
||||
print "remove: %s" % repo_file
|
||||
visit_files(repo.path, visit_repo, MBED_REPO_EXT)
|
||||
|
||||
repo.publish()
|
||||
update_repo(repo_name, sdk_path)
|
||||
|
||||
|
||||
def update_dependencies(repositories):
|
||||
|
@ -167,17 +172,25 @@ def update_dependencies(repositories):
|
|||
repo.publish()
|
||||
|
||||
|
||||
def update_mbed():
|
||||
update_repo("mbed", join(BUILD_DIR, "mbed"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = OptionParser()
|
||||
|
||||
parser.add_option("-c", "--code", dest="code",
|
||||
parser.add_option("-c", "--code",
|
||||
action="store_true", default=False,
|
||||
help="Update the mbed_official code")
|
||||
|
||||
parser.add_option("-d", "--dependencies", dest="dependencies",
|
||||
parser.add_option("-d", "--dependencies",
|
||||
action="store_true", default=False,
|
||||
help="Update the mbed_official code dependencies")
|
||||
|
||||
parser.add_option("-m", "--mbed",
|
||||
action="store_true", default=False,
|
||||
help="Release a build of the mbed library")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.code:
|
||||
|
@ -185,3 +198,7 @@ if __name__ == '__main__':
|
|||
|
||||
if options.dependencies:
|
||||
update_dependencies(CODE_WITH_DEPENDENCIES)
|
||||
|
||||
if options.mbed:
|
||||
update_mbed()
|
||||
|
||||
|
|
|
@ -163,6 +163,15 @@ class MBED_MCU(Target):
|
|||
|
||||
self.supported_toolchains = ["ARM"]
|
||||
|
||||
class LPC1347(Target):
|
||||
def __init__(self):
|
||||
Target.__init__(self)
|
||||
|
||||
self.core = "Cortex-M3"
|
||||
|
||||
self.extra_labels = ['NXP', 'LPC13XX']
|
||||
|
||||
self.supported_toolchains = ["ARM", "GCC_ARM"]
|
||||
|
||||
# Get a single instance for each target
|
||||
TARGETS = [
|
||||
|
@ -175,7 +184,8 @@ TARGETS = [
|
|||
LPC4088(),
|
||||
LPC4330_M4(),
|
||||
STM32F407(),
|
||||
MBED_MCU()
|
||||
MBED_MCU(),
|
||||
LPC1347()
|
||||
]
|
||||
|
||||
# Map each target name to its unique instance
|
||||
|
|
|
@ -332,6 +332,12 @@ TESTS = [
|
|||
"automated": True,
|
||||
"peripherals": ["ADXL345"]
|
||||
},
|
||||
{
|
||||
"id": "MBED_28", "description": "I2C EEPROM read/write test",
|
||||
"source_dir": join(TEST_DIR, "mbed", "i2c_eeprom"),
|
||||
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
|
||||
"automated": True,
|
||||
},
|
||||
{
|
||||
"id": "MBED_29", "description": "I2C master/slave test",
|
||||
"source_dir": join(TEST_DIR, "mbed", "i2c_master_slave"),
|
||||
|
@ -535,19 +541,16 @@ TESTS = [
|
|||
"id": "USB_1", "description": "Mouse",
|
||||
"source_dir": join(TEST_DIR, "usb", "device", "basic"),
|
||||
"dependencies": [MBED_LIBRARIES, USB_LIBRARIES],
|
||||
"supported": CORTEX_ARM_SUPPORT,
|
||||
},
|
||||
{
|
||||
"id": "USB_2", "description": "Keyboard",
|
||||
"source_dir": join(TEST_DIR, "usb", "device", "keyboard"),
|
||||
"dependencies": [MBED_LIBRARIES, USB_LIBRARIES],
|
||||
"supported": CORTEX_ARM_SUPPORT,
|
||||
},
|
||||
{
|
||||
"id": "USB_3", "description": "Mouse_Keyboard",
|
||||
"source_dir": join(TEST_DIR, "usb", "device", "keyboard"),
|
||||
"dependencies": [MBED_LIBRARIES, USB_LIBRARIES],
|
||||
"supported": CORTEX_ARM_SUPPORT,
|
||||
},
|
||||
{
|
||||
"id": "USB_4", "description": "Serial Port",
|
||||
|
@ -559,19 +562,16 @@ TESTS = [
|
|||
"id": "USB_5", "description": "Generic HID",
|
||||
"source_dir": join(TEST_DIR, "usb", "device", "raw_hid"),
|
||||
"dependencies": [MBED_LIBRARIES, USB_LIBRARIES],
|
||||
"supported": CORTEX_ARM_SUPPORT,
|
||||
},
|
||||
{
|
||||
"id": "USB_6", "description": "MIDI",
|
||||
"source_dir": join(TEST_DIR, "usb", "device", "midi"),
|
||||
"dependencies": [MBED_LIBRARIES, USB_LIBRARIES],
|
||||
"supported": CORTEX_ARM_SUPPORT,
|
||||
},
|
||||
{
|
||||
"id": "USB_7", "description": "AUDIO",
|
||||
"source_dir": join(TEST_DIR, "usb", "device", "audio"),
|
||||
"dependencies": [MBED_LIBRARIES, USB_LIBRARIES],
|
||||
"supported": CORTEX_ARM_SUPPORT,
|
||||
},
|
||||
|
||||
# CMSIS DSP
|
||||
|
@ -650,7 +650,7 @@ class Test:
|
|||
self.n = n
|
||||
self.__dict__.update(Test.DEFAULTS)
|
||||
self.__dict__.update(TESTS[n])
|
||||
|
||||
|
||||
def is_supported(self, target, toolchain):
|
||||
if not hasattr(self, 'supported'):
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue