diff options
Diffstat (limited to 'os')
-rw-r--r-- | os/common/ports/ARMCMx/compilers/GCC/ld/STM32F429xI.ld | 54 | ||||
-rw-r--r-- | os/various/devices_lib/lcd/ili9341.c (renamed from os/various/devices_lib/others/ili9341.c) | 0 | ||||
-rw-r--r-- | os/various/devices_lib/lcd/ili9341.h (renamed from os/various/devices_lib/others/ili9341.h) | 0 | ||||
-rw-r--r-- | os/various/memtest.cpp | 286 | ||||
-rw-r--r-- | os/various/memtest.hpp | 73 |
5 files changed, 359 insertions, 54 deletions
diff --git a/os/common/ports/ARMCMx/compilers/GCC/ld/STM32F429xI.ld b/os/common/ports/ARMCMx/compilers/GCC/ld/STM32F429xI.ld deleted file mode 100644 index 1fb424a..0000000 --- a/os/common/ports/ARMCMx/compilers/GCC/ld/STM32F429xI.ld +++ /dev/null @@ -1,54 +0,0 @@ -/*
- ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio.
-
- This file is part of ChibiOS.
-
- ChibiOS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/*
- * ST32F429xI memory setup.
- * Note: Use of ram1, ram2 and ram3 is mutually exclusive with use of ram0.
- */
-MEMORY
-{
- flash : org = 0x08000000, len = 2M
- ram0 : org = 0x20000000, len = 192k /* SRAM1 + SRAM2 + SRAM3 */
- ram1 : org = 0x20000000, len = 112k /* SRAM1 */
- ram2 : org = 0x2001C000, len = 16k /* SRAM2 */
- ram3 : org = 0x20020000, len = 64k /* SRAM3 */
- ram4 : org = 0x10000000, len = 64k /* CCM SRAM */
- ram5 : org = 0x40024000, len = 4k /* BCKP SRAM */
- ram6 : org = 0x00000000, len = 0
- ram7 : org = 0xD0000000, len = 8M /* SDRAM */
-}
-
-/* RAM region to be used for Main stack. This stack accommodates the processing
- of all exceptions and interrupts*/
-REGION_ALIAS("MAIN_STACK_RAM", ram0);
-
-/* RAM region to be used for the process stack. This is the stack used by
- the main() function.*/
-REGION_ALIAS("PROCESS_STACK_RAM", ram0);
-
-/* RAM region to be used for data segment.*/
-REGION_ALIAS("DATA_RAM", ram0);
-
-/* RAM region to be used for BSS segment.*/
-REGION_ALIAS("BSS_RAM", ram0);
-
-/* RAM region to be used for SDRAM segment.*/
-REGION_ALIAS("SDRAM_RAM", ram7);
-
-INCLUDE rules.ld
diff --git a/os/various/devices_lib/others/ili9341.c b/os/various/devices_lib/lcd/ili9341.c index 979e502..979e502 100644 --- a/os/various/devices_lib/others/ili9341.c +++ b/os/various/devices_lib/lcd/ili9341.c diff --git a/os/various/devices_lib/others/ili9341.h b/os/various/devices_lib/lcd/ili9341.h index 007c4fd..007c4fd 100644 --- a/os/various/devices_lib/others/ili9341.h +++ b/os/various/devices_lib/lcd/ili9341.h diff --git a/os/various/memtest.cpp b/os/various/memtest.cpp new file mode 100644 index 0000000..49828ec --- /dev/null +++ b/os/various/memtest.cpp @@ -0,0 +1,286 @@ +/* + ChibiOS/RT - Copyright (C) 2013-2014 Uladzimir Pylinsky aka barthess + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include <stdint.h> +#include <stddef.h> +#include <stdlib.h> + +#include "memtest.hpp" + +/* + * + */ +template <typename T> +class Generator { +public: + Generator(void) : pattern(0) {;} + virtual T get(void) = 0; + virtual testtype get_type(void) = 0; + virtual void init(T seed) { + pattern = seed; + } +protected: + T pattern; +}; + +/* + * + */ +template <typename T> +class GeneratorWalkingOne : public Generator<T> { + T get(void) { + T ret = this->pattern; + + this->pattern <<= 1; + if (0 == this->pattern) + this->pattern = 1; + + return ret; + } + + testtype get_type(void) { + return MEMTEST_WALKING_ONE; + } +}; + +/* + * + */ +template <typename T> +class GeneratorWalkingZero : public Generator<T> { + T get(void) { + T ret = ~this->pattern; + + this->pattern <<= 1; + if (0 == this->pattern) + this->pattern = 1; + + return ret; + } + + testtype get_type(void) { + return MEMTEST_WALKING_ZERO; + } +}; + +/* + * + */ +template <typename T> +class GeneratorOwnAddress : public Generator<T> { + T get(void) { + T ret = this->pattern; + this->pattern++; + return ret; + } + + testtype get_type(void) { + return MEMTEST_OWN_ADDRESS; + } +}; + +/* + * + */ +template <typename T> +class GeneratorMovingInv : public Generator<T> { + T get(void) { + T ret = this->pattern; + this->pattern = ~this->pattern; + return ret; + } + + testtype get_type(void) { + if ((this->pattern == 0) || ((this->pattern & 0xFF) == 0xFF)) + return MEMTEST_MOVING_INVERSION_ZERO; + else + return MEMTEST_MOVING_INVERSION_55AA; + } +}; + +/* + * + */ +template <typename T> +class GeneratorMovingInvRand : public Generator<T> { +public: + GeneratorMovingInvRand(void) : step(0), prev(0){;} + void init(T seed) { + srand(seed); + step = 0; + prev = 0; + } + + T get(void) { + T ret; + T mask = -1; + if ((step & 1) == 0) { + ret = rand() & mask; + prev = ret; + } + else { + ret = ~prev & mask; + } + step++; + + return ret; + } + + testtype get_type(void) { + return MEMTEST_MOVING_INVERSION_RAND; + } + +private: + size_t step; + T prev; +}; + +/* + * + */ +template <typename T> +static void memtest_sequential(memtest_t *testp, Generator<T> &generator, T seed) { + const size_t steps = testp->size / sizeof(T); + size_t i; + T *mem = static_cast<T *>(testp->start); + + /* fill ram */ + generator.init(seed); + for (i=0; i<steps; i++) + mem[i] = generator.get(); + + /* read back and compare */ + generator.init(seed); + for (i=0; i<steps; i++) { + if (mem[i] != generator.get()) { + testp->ecb(testp, generator.get_type(), i*sizeof(T)); + return; + } + } +} + +template <typename T> +static void walking_one(memtest_t *testp) { + GeneratorWalkingOne<T> generator; + memtest_sequential<T>(testp, generator, 1); +} + +template <typename T> +static void walking_zero(memtest_t *testp) { + GeneratorWalkingZero<T> generator; + memtest_sequential<T>(testp, generator, 1); +} + +template <typename T> +static void own_address(memtest_t *testp) { + GeneratorOwnAddress<T> generator; + memtest_sequential<T>(testp, generator, 0); +} + +template <typename T> +static void moving_inversion_zero(memtest_t *testp) { + GeneratorMovingInv<T> generator; + T mask = -1; + memtest_sequential<T>(testp, generator, 0); + memtest_sequential<T>(testp, generator, 0xFFFFFFFF & mask); +} + +template <typename T> +static void moving_inversion_55aa(memtest_t *testp) { + GeneratorMovingInv<T> generator; + T mask = -1; + memtest_sequential<T>(testp, generator, 0x55555555 & mask); + memtest_sequential<T>(testp, generator, 0xAAAAAAAA & mask); +} + +template <typename T> +static void moving_inversion_rand(memtest_t *testp) { + GeneratorMovingInvRand<T> generator; + T mask = -1; + memtest_sequential<T>(testp, generator, testp->rand_seed & mask); +} + +/* + * + */ +static void memtest_wrapper(memtest_t *testp, + void (*p_u8)(memtest_t *testp), + void (*p_u16)(memtest_t *testp), + void (*p_u32)(memtest_t *testp)) { + switch(testp->width) { + case MEMTEST_WIDTH_32: + p_u8(testp); + p_u16(testp); + p_u32(testp); + break; + case MEMTEST_WIDTH_16: + p_u8(testp); + p_u16(testp); + break; + case MEMTEST_WIDTH_8: + p_u8(testp); + break; + } +} + +/* + * + */ +void memtest_run(memtest_t *testp, uint32_t testmask) { + + if (testmask & MEMTEST_WALKING_ONE) { + memtest_wrapper(testp, + walking_one<uint8_t>, + walking_one<uint16_t>, + walking_one<uint32_t>); + } + + if (testmask & MEMTEST_WALKING_ZERO) { + memtest_wrapper(testp, + walking_zero<uint8_t>, + walking_zero<uint16_t>, + walking_zero<uint32_t>); + } + + if (testmask & MEMTEST_OWN_ADDRESS) { + memtest_wrapper(testp, + own_address<uint8_t>, + own_address<uint16_t>, + own_address<uint32_t>); + } + + if (testmask & MEMTEST_MOVING_INVERSION_ZERO) { + memtest_wrapper(testp, + moving_inversion_zero<uint8_t>, + moving_inversion_zero<uint16_t>, + moving_inversion_zero<uint32_t>); + } + + if (testmask & MEMTEST_MOVING_INVERSION_55AA) { + memtest_wrapper(testp, + moving_inversion_55aa<uint8_t>, + moving_inversion_55aa<uint16_t>, + moving_inversion_55aa<uint32_t>); + } + + if (testmask & MEMTEST_MOVING_INVERSION_RAND) { + memtest_wrapper(testp, + moving_inversion_rand<uint8_t>, + moving_inversion_rand<uint16_t>, + moving_inversion_rand<uint32_t>); + } +} + diff --git a/os/various/memtest.hpp b/os/various/memtest.hpp new file mode 100644 index 0000000..200db1f --- /dev/null +++ b/os/various/memtest.hpp @@ -0,0 +1,73 @@ +/* + ChibiOS/RT - Copyright (C) 2013-2014 Uladzimir Pylinsky aka barthess + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef MEMTEST_HPP_ +#define MEMTEST_HPP_ + +#define MEMTEST_WALKING_ONE (1 << 0) +#define MEMTEST_WALKING_ZERO (1 << 1) +#define MEMTEST_OWN_ADDRESS (1 << 2) +#define MEMTEST_MOVING_INVERSION_ZERO (1 << 3) +#define MEMTEST_MOVING_INVERSION_55AA (1 << 4) +#define MEMTEST_MOVING_INVERSION_RAND (1 << 5) + +#define MEMTEST_RUN_ALL (MEMTEST_WALKING_ONE | \ + MEMTEST_WALKING_ZERO | \ + MEMTEST_OWN_ADDRESS | \ + MEMTEST_MOVING_INVERSION_ZERO | \ + MEMTEST_MOVING_INVERSION_55AA | \ + MEMTEST_MOVING_INVERSION_RAND) + +typedef struct memtest_t memtest_t; +typedef uint32_t testtype; + +/* + * Error call back. + */ +typedef void (*memtestecb_t)(memtest_t *testp, testtype type, size_t address); + +/* + * + */ +typedef enum { + MEMTEST_WIDTH_8, + MEMTEST_WIDTH_16, + MEMTEST_WIDTH_32 +} memtest_bus_width_t; + +/* + * + */ +struct memtest_t { + void *start; + size_t size; + memtest_bus_width_t width; + memtestecb_t ecb; + unsigned int rand_seed; +}; + +/* + * + */ +#ifdef __cplusplus +extern "C" { +#endif + void memtest_run(memtest_t *testp, uint32_t testmask); +#ifdef __cplusplus +} +#endif + +#endif /* MEMTEST_HPP_ */ |