There is a book about a boy who gains powers all of a sudden. He goes to a special school, and he meets people who have other types of powers; for instance, one of his friends had perfect photographic memory, and there is a girl. I think it talks a little about Charlemagne, and he tries to learn about his past. Anyone know its name?
It's possible you're thinking of Jenny Nimmo's Children of the Red King series. With enough lateral thinking, it matches all of what you mentioned in the question:
a boy who gains powers all of a sudden
In the first book, Charlie Bone (the protagonist) learns unexpectedly that he has a magical ability ...
He goes to a special school,
... which means he is sent to Bloor's Academy, a unique school dedicated to ...
and he meets people who have other types of powers;
... children with endowments: the word used in the series for the magical powers inherited by some descendants of the semi-legendary Red King.
for instance, one of his friend had perfect photographic memory,
By simply looking at a photograph, Charlie can hear the voices of the people in it at the time the photo was taken, as though he was actually there. This is his endowment. Sometimes he even manages to enter into the photo and interact with the people in it.
and there is a girl.
There's more than one girl in the series! You may be thinking of Olivia, a good friend of Charlie's who at first doesn't seem to be endowed but later discovers her latent powers, or the mysterious Emila Moon (Emma Tolly).
I think it talks a little about Charlemagne,
Here you may be mixing up the character of the Red King with the name of Charlie Bone.
and he tries to learn about his past.
As in many fantasy novels, the protagonist learning about his own past is a key plot point. In particular, Charlie's father went missing years before the series started, and the quest to find out what really happened to him is an important part of the story.
It's actually a fairly well known book (for book readers anyway), because there's a lot of similarities between it and Harry Potter. The book's name is Wizard's Hall.