On 28/02/18 08:31, Jack wrote:
> Il giorno martedì 27 febbraio 2018 19:11:09 UTC+1, Ilias Abrams ha
> scritto:
>> Τη Τρίτη, 27 Φεβρουαρίου 2018 - 1:34:17 μ.μ. UTC, ο χρήστης David
>> Brown έγραψε:
>>> On 27/02/18 11:34, Ilias Abrams wrote:
>>>> Τη Τρίτη, 27 Φεβρουαρίου 2018 - 7:51:33 π.μ. UTC, ο χρήστης
>>>> David Brown έγραψε:
>>>>>
>>>>> What sort of systems are you talking about here? Very
>>>>> roughly, you can divide processors into two categories.
>>>>>
>>>>
>>>>>
>>>>> And there are "small" ones designed for running a single
>>>>> program, either "bare metal" or with a small "real-time
>>>>> operating system", with all the code compiled and linked at
>>>>> one time. Then the logical addresses and physical addresses
>>>>> are the same, and you often don't have any kind of memory
>>>>> protection at all.
>>>>>
>>>>>
>>>> Thanks David, I would like to focus on this more. The 1GB
>>>> memory that I said is only for example. Can you please give
>>>> more details? Microcontrollers work on that way? Basically I
>>>> want to write a program with no OS. Only my software run on the
>>>> hardware and have 1-1 mapping meaning my physical address space
>>>> translated to logical addresses. I dont know so much yet about
>>>> programming but I think that C make use of the logical
>>>> addresses and not the physical but with 1-1 mapping maybe can
>>>> achieve this.
>>>>
>>>
>>> You are not making much sense here. It is like saying you'd like
>>> to go on a car holiday, and would prefer a manual gear car to an
>>> automatic. No one could give you advice because they don't know
>>> where you want to go, what you want to do, if you want to buy a
>>> care or hire it, or anything else.
>>>
>>> Or it is like going to an author's conference and saying "I'd
>>> like to write a book. Perhaps it will be hardback, but that's
>>> just an example. Do the numbers on the bottom of the pages match
>>> the physical sheets of paper in book printing?"
>>>
>>> Saying "I want to write a program" is equally vague. We have no
>>> idea if you are trying to program on a PC, or have bought a
>>> microcontroller based embedded card, or even if you have a target
>>> at all. We have no idea what your program would be doing, or
>>> what you know or don't know about the matter.
>>>
>>> We don't know if you are a student trying to get help with some
>>> homework, a professional who has been given a task way outside
>>> your experience, or a hobby developer just trying to learn
>>> something new.
>>>
>>> You have to take a step back and think about what you know, and
>>> where you want to go, and try to give a better description of it.
>>> And be ready for when the advice you get is "don't start with C"
>>> or "don't worry about physical memory mappings - you'll get there
>>> in a couple of years".
>>
>> You are absolutely right. Lets start again, I am a student and I
>> have a project. I want to work on ARM architecture and not on x86.
>> I am working some C examples on RPI2 and 3 and also I have a
>> microcontroller Tiva C TM4C123G Launchpad. I want to right a
>> baremetal software that can save registers values into the memory
>> address like stack lets say and print those values from memory to
>> screen. But I want to use C and assembly (maybe inline assembly)
>> and I want to use physical addresses (If its not possible to use
>> directly the physical addresses maybe I can achieve a 1-1 mapping
>> logical to physical) What are your thoughts about that? Can you
>> guide me what I have to do? Thanks!
>
> Guide you is the job of your professor, he is paid for it, so use
> him.
>
> Said that, forget the RPi, you can't use it bare metal, too
> complicated.
>
> Start with an Arduino (but it's not ARM) or some board from mbed.org
> (they have ARM). Start with something simple, like an ARM of the
> Cortex M family (there is a good book about the Cortex M: "The
> Definitive Guide to ARM Cortex M", you'll find it on Amazon).
>
> If you want to start with something smaller Atmel AVR are good (used
> in Arduino), or NXP (Freescale) HCS08 (Book: "HCS08 Unleashed", very
> good, with examples).
>
I am sceptical to Arduino. It is easy to get started with, but gives
you a sort of half-C, half-C++ environment with far too many of the
important bits hidden away. You can't control the compiler properly,
you can't get warnings properly, you can't even see where the code you
are using comes from because headers are hidden. There is a lot of
lasagne programming (something as simple as controlling a GPIO pin, that
is a single instruction on an AVR, goes up and down through half a dozen
layers of "abstraction"). Yes, you can quickly do simple things with it
- but it does not teach you good programming or development practices,
and is not a way to make early versions of code. It would have been a
better system if they had used a language like BASIC rather than their
C/C++ hybrid, as it would then be clear that you are using it for
experimentation and testing ideas, not for developing a final system.
I am also highly sceptical to recommending the HCS08 - or any of the old
8-bit CISC cores. These have played their part in the embedded world,
many of them for far longer than they should have. Let them go, and let
their old non-standard tools go with them. For anyone getting into this
game now, pick a device with good, modern compiler support that you can
program in real standard C or C++. The AVR is a border-line case - you
can use normal standard programming for everything except constant data
in flash memory. I'd say it's okay for small uses, but once you have
more than 64K devices you are back in the mess of segmented memories.
(The same applies to msp430 over 64K - up to that limit, it is very
nice, clean 16-bit architecture.)
The standard today for small systems is Cortex-M. If you are learning
embedded programming, use devices with these cores. The other realistic
cores are MIPS (for the PIC32) and - I hope - RISC-V in more future
devices. But the great thing about using a decent core that can be used
with standard C and C++ programming using top-line tools is that the
core becomes mostly irrelevant. You don't have to learn "C programming
for the AVR", or "C programming for the 8051", with all their
idiosyncrasies and odd extensions - you just learn "C programming" and
it works on them all.
The decision then comes down to the kind of hardware you want, the kind
of demo boards that suit your interests, the kind of software support
(libraries, demo code, etc.) that suits you.
Of course, if you just want to get a taste for embedded programming and
controlling things, forget all about individual boards and buy a Lego
Mindstorms kit. That will get you the feeling of building and
controlling stuff far faster, and you can move on from there.